@@ -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(); |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Gets all the spotter information based on the latest data entry |
|
100 | - * |
|
101 | - * @return Array the spotter information |
|
102 | - * |
|
103 | - */ |
|
99 | + * Gets all the spotter information based on the latest data entry |
|
100 | + * |
|
101 | + * @return Array the spotter information |
|
102 | + * |
|
103 | + */ |
|
104 | 104 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
105 | 105 | { |
106 | 106 | global $globalDBdriver, $globalLiveInterval; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | - * Gets Minimal Live Spotter data |
|
147 | - * |
|
148 | - * @return Array the spotter information |
|
149 | - * |
|
150 | - */ |
|
146 | + * Gets Minimal Live Spotter data |
|
147 | + * |
|
148 | + * @return Array the spotter information |
|
149 | + * |
|
150 | + */ |
|
151 | 151 | public function getMinLiveMarineData($filter = array()) |
152 | 152 | { |
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | - * Gets Minimal Live Spotter data since xx seconds |
|
181 | - * |
|
182 | - * @return Array the spotter information |
|
183 | - * |
|
184 | - */ |
|
180 | + * Gets Minimal Live Spotter data since xx seconds |
|
181 | + * |
|
182 | + * @return Array the spotter information |
|
183 | + * |
|
184 | + */ |
|
185 | 185 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Gets number of latest data entry |
|
265 | - * |
|
266 | - * @return String number of entry |
|
267 | - * |
|
268 | - */ |
|
264 | + * Gets number of latest data entry |
|
265 | + * |
|
266 | + * @return String number of entry |
|
267 | + * |
|
268 | + */ |
|
269 | 269 | public function getLiveMarineCount($filter = array()) |
270 | 270 | { |
271 | 271 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Gets all the spotter information based on the latest data entry and coord |
|
294 | - * |
|
295 | - * @return Array the spotter information |
|
296 | - * |
|
297 | - */ |
|
293 | + * Gets all the spotter information based on the latest data entry and coord |
|
294 | + * |
|
295 | + * @return Array the spotter information |
|
296 | + * |
|
297 | + */ |
|
298 | 298 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
299 | 299 | { |
300 | 300 | global $globalDBdriver, $globalLiveInterval; |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | - * Gets all the spotter information based on the latest data entry and coord |
|
322 | - * |
|
323 | - * @return Array the spotter information |
|
324 | - * |
|
325 | - */ |
|
321 | + * Gets all the spotter information based on the latest data entry and coord |
|
322 | + * |
|
323 | + * @return Array the spotter information |
|
324 | + * |
|
325 | + */ |
|
326 | 326 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
327 | 327 | { |
328 | 328 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
400 | 400 | { |
401 | 401 | $Marine = new Marine($this->db); |
@@ -408,75 +408,75 @@ discard block |
||
408 | 408 | if ($lng != '') |
409 | 409 | { |
410 | 410 | if (!is_numeric($lng)) |
411 | - { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ($radius != '') |
|
417 | - { |
|
418 | - if (!is_numeric($radius)) |
|
419 | - { |
|
420 | - return false; |
|
421 | - } |
|
422 | - } |
|
411 | + { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ($radius != '') |
|
417 | + { |
|
418 | + if (!is_numeric($radius)) |
|
419 | + { |
|
420 | + return false; |
|
421 | + } |
|
422 | + } |
|
423 | 423 | $additional_query = ''; |
424 | 424 | if ($interval != '') |
425 | - { |
|
426 | - if (!is_string($interval)) |
|
427 | - { |
|
428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
429 | - return false; |
|
430 | - } else { |
|
431 | - if ($interval == '1m') |
|
432 | - { |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
434 | - } else if ($interval == '15m'){ |
|
435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
436 | - } |
|
437 | - } |
|
438 | - } else { |
|
439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
440 | - } |
|
441 | - |
|
442 | - $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 | + { |
|
426 | + if (!is_string($interval)) |
|
427 | + { |
|
428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
429 | + return false; |
|
430 | + } else { |
|
431 | + if ($interval == '1m') |
|
432 | + { |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
434 | + } else if ($interval == '15m'){ |
|
435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
436 | + } |
|
437 | + } |
|
438 | + } else { |
|
439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
440 | + } |
|
441 | + |
|
442 | + $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 |
|
443 | 443 | WHERE marine_live.latitude <> '' |
444 | 444 | AND marine_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
450 | 450 | |
451 | - return $spotter_array; |
|
452 | - } |
|
451 | + return $spotter_array; |
|
452 | + } |
|
453 | 453 | |
454 | 454 | |
455 | - /** |
|
456 | - * Gets all the spotter information based on a particular callsign |
|
457 | - * |
|
458 | - * @return Array the spotter information |
|
459 | - * |
|
460 | - */ |
|
455 | + /** |
|
456 | + * Gets all the spotter information based on a particular callsign |
|
457 | + * |
|
458 | + * @return Array the spotter information |
|
459 | + * |
|
460 | + */ |
|
461 | 461 | public function getLastLiveMarineDataByIdent($ident) |
462 | 462 | { |
463 | 463 | $Marine = new Marine($this->db); |
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | 469 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Gets all the spotter information based on a particular callsign |
|
476 | - * |
|
477 | - * @return Array the spotter information |
|
478 | - * |
|
479 | - */ |
|
474 | + /** |
|
475 | + * Gets all the spotter information based on a particular callsign |
|
476 | + * |
|
477 | + * @return Array the spotter information |
|
478 | + * |
|
479 | + */ |
|
480 | 480 | public function getDateLiveMarineDataByIdent($ident,$date) |
481 | 481 | { |
482 | 482 | $Marine = new Marine($this->db); |
@@ -489,11 +489,11 @@ discard block |
||
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
492 | - * Gets all the spotter information based on a particular MMSI |
|
493 | - * |
|
494 | - * @return Array the spotter information |
|
495 | - * |
|
496 | - */ |
|
492 | + * Gets all the spotter information based on a particular MMSI |
|
493 | + * |
|
494 | + * @return Array the spotter information |
|
495 | + * |
|
496 | + */ |
|
497 | 497 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
498 | 498 | { |
499 | 499 | $Marine = new Marine($this->db); |
@@ -505,51 +505,51 @@ discard block |
||
505 | 505 | return $spotter_array; |
506 | 506 | } |
507 | 507 | |
508 | - /** |
|
509 | - * Gets last spotter information based on a particular callsign |
|
510 | - * |
|
511 | - * @return Array the spotter information |
|
512 | - * |
|
513 | - */ |
|
508 | + /** |
|
509 | + * Gets last spotter information based on a particular callsign |
|
510 | + * |
|
511 | + * @return Array the spotter information |
|
512 | + * |
|
513 | + */ |
|
514 | 514 | public function getLastLiveMarineDataById($id) |
515 | 515 | { |
516 | 516 | $Marine = new Marine($this->db); |
517 | 517 | date_default_timezone_set('UTC'); |
518 | 518 | |
519 | 519 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
520 | - $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'; |
|
520 | + $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'; |
|
521 | 521 | |
522 | 522 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
523 | 523 | |
524 | 524 | return $spotter_array; |
525 | 525 | } |
526 | 526 | |
527 | - /** |
|
528 | - * Gets last spotter information based on a particular callsign |
|
529 | - * |
|
530 | - * @return Array the spotter information |
|
531 | - * |
|
532 | - */ |
|
527 | + /** |
|
528 | + * Gets last spotter information based on a particular callsign |
|
529 | + * |
|
530 | + * @return Array the spotter information |
|
531 | + * |
|
532 | + */ |
|
533 | 533 | public function getDateLiveMarineDataById($id,$date) |
534 | 534 | { |
535 | 535 | $Marine = new Marine($this->db); |
536 | 536 | date_default_timezone_set('UTC'); |
537 | 537 | |
538 | 538 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
539 | - $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'; |
|
540 | - $date = date('c',$date); |
|
539 | + $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'; |
|
540 | + $date = date('c',$date); |
|
541 | 541 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
542 | 542 | |
543 | 543 | return $spotter_array; |
544 | 544 | } |
545 | 545 | |
546 | 546 | |
547 | - /** |
|
548 | - * Gets all the spotter information based on a particular id |
|
549 | - * |
|
550 | - * @return Array the spotter information |
|
551 | - * |
|
552 | - */ |
|
547 | + /** |
|
548 | + * Gets all the spotter information based on a particular id |
|
549 | + * |
|
550 | + * @return Array the spotter information |
|
551 | + * |
|
552 | + */ |
|
553 | 553 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
554 | 554 | { |
555 | 555 | global $globalDBdriver, $globalLiveInterval; |
@@ -577,18 +577,18 @@ discard block |
||
577 | 577 | return $spotter_array; |
578 | 578 | } |
579 | 579 | |
580 | - /** |
|
581 | - * Gets all the spotter information based on a particular ident |
|
582 | - * |
|
583 | - * @return Array the spotter information |
|
584 | - * |
|
585 | - */ |
|
580 | + /** |
|
581 | + * Gets all the spotter information based on a particular ident |
|
582 | + * |
|
583 | + * @return Array the spotter information |
|
584 | + * |
|
585 | + */ |
|
586 | 586 | public function getAllLiveMarineDataByIdent($ident) |
587 | 587 | { |
588 | 588 | date_default_timezone_set('UTC'); |
589 | 589 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
590 | 590 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
591 | - try { |
|
591 | + try { |
|
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(array(':ident' => $ident)); |
@@ -602,23 +602,23 @@ discard block |
||
602 | 602 | |
603 | 603 | |
604 | 604 | /** |
605 | - * Deletes all info in the table |
|
606 | - * |
|
607 | - * @return String success or false |
|
608 | - * |
|
609 | - */ |
|
605 | + * Deletes all info in the table |
|
606 | + * |
|
607 | + * @return String success or false |
|
608 | + * |
|
609 | + */ |
|
610 | 610 | public function deleteLiveMarineData() |
611 | 611 | { |
612 | 612 | global $globalDBdriver; |
613 | 613 | if ($globalDBdriver == 'mysql') { |
614 | 614 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
615 | 615 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
616 | - //$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)"; |
|
616 | + //$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)"; |
|
617 | 617 | } else { |
618 | 618 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
619 | 619 | } |
620 | 620 | |
621 | - try { |
|
621 | + try { |
|
622 | 622 | |
623 | 623 | $sth = $this->db->prepare($query); |
624 | 624 | $sth->execute(); |
@@ -630,18 +630,18 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
634 | - * |
|
635 | - * @return String success or false |
|
636 | - * |
|
637 | - */ |
|
633 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
634 | + * |
|
635 | + * @return String success or false |
|
636 | + * |
|
637 | + */ |
|
638 | 638 | public function deleteLiveMarineDataNotUpdated() |
639 | 639 | { |
640 | 640 | global $globalDBdriver, $globalDebug; |
641 | 641 | if ($globalDBdriver == 'mysql') { |
642 | 642 | //$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'; |
643 | - $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"; |
|
644 | - try { |
|
643 | + $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"; |
|
644 | + try { |
|
645 | 645 | |
646 | 646 | $sth = $this->db->prepare($query); |
647 | 647 | $sth->execute(); |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | return "error"; |
650 | 650 | } |
651 | 651 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
652 | - $i = 0; |
|
653 | - $j =0; |
|
652 | + $i = 0; |
|
653 | + $j =0; |
|
654 | 654 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | 655 | foreach($all as $row) |
656 | 656 | { |
@@ -658,20 +658,20 @@ discard block |
||
658 | 658 | $j++; |
659 | 659 | if ($j == 30) { |
660 | 660 | if ($globalDebug) echo "."; |
661 | - try { |
|
661 | + try { |
|
662 | 662 | |
663 | 663 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
664 | 664 | $sth->execute(); |
665 | 665 | } catch(PDOException $e) { |
666 | 666 | return "error"; |
667 | 667 | } |
668 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
669 | - $j = 0; |
|
668 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
669 | + $j = 0; |
|
670 | 670 | } |
671 | 671 | $query_delete .= "'".$row['fammarine_id']."',"; |
672 | 672 | } |
673 | 673 | if ($i > 0) { |
674 | - try { |
|
674 | + try { |
|
675 | 675 | |
676 | 676 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
677 | 677 | $sth->execute(); |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | return "success"; |
683 | 683 | } elseif ($globalDBdriver == 'pgsql') { |
684 | 684 | //$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"; |
685 | - //$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"; |
|
686 | - $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)"; |
|
687 | - try { |
|
685 | + //$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"; |
|
686 | + $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)"; |
|
687 | + try { |
|
688 | 688 | |
689 | 689 | $sth = $this->db->prepare($query); |
690 | 690 | $sth->execute(); |
@@ -728,17 +728,17 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * Deletes all info in the table for an ident |
|
732 | - * |
|
733 | - * @return String success or false |
|
734 | - * |
|
735 | - */ |
|
731 | + * Deletes all info in the table for an ident |
|
732 | + * |
|
733 | + * @return String success or false |
|
734 | + * |
|
735 | + */ |
|
736 | 736 | public function deleteLiveMarineDataByIdent($ident) |
737 | 737 | { |
738 | 738 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
739 | 739 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
740 | 740 | |
741 | - try { |
|
741 | + try { |
|
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(array(':ident' => $ident)); |
@@ -750,17 +750,17 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
753 | - * Deletes all info in the table for an id |
|
754 | - * |
|
755 | - * @return String success or false |
|
756 | - * |
|
757 | - */ |
|
753 | + * Deletes all info in the table for an id |
|
754 | + * |
|
755 | + * @return String success or false |
|
756 | + * |
|
757 | + */ |
|
758 | 758 | public function deleteLiveMarineDataById($id) |
759 | 759 | { |
760 | 760 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
761 | 761 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
762 | 762 | |
763 | - try { |
|
763 | + try { |
|
764 | 764 | |
765 | 765 | $sth = $this->db->prepare($query); |
766 | 766 | $sth->execute(array(':id' => $id)); |
@@ -773,11 +773,11 @@ discard block |
||
773 | 773 | |
774 | 774 | |
775 | 775 | /** |
776 | - * Gets the marine races |
|
777 | - * |
|
778 | - * @return Array all races |
|
779 | - * |
|
780 | - */ |
|
776 | + * Gets the marine races |
|
777 | + * |
|
778 | + * @return Array all races |
|
779 | + * |
|
780 | + */ |
|
781 | 781 | public function getAllRaces() |
782 | 782 | { |
783 | 783 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -787,11 +787,11 @@ discard block |
||
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
790 | - * Gets the aircraft ident within the last hour |
|
791 | - * |
|
792 | - * @return String the ident |
|
793 | - * |
|
794 | - */ |
|
790 | + * Gets the aircraft ident within the last hour |
|
791 | + * |
|
792 | + * @return String the ident |
|
793 | + * |
|
794 | + */ |
|
795 | 795 | public function getIdentFromLastHour($ident) |
796 | 796 | { |
797 | 797 | global $globalDBdriver, $globalTimezone; |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | $ident_result = $row['ident']; |
818 | 818 | } |
819 | 819 | return $ident_result; |
820 | - } |
|
820 | + } |
|
821 | 821 | |
822 | 822 | /** |
823 | - * Check recent aircraft |
|
824 | - * |
|
825 | - * @return String the ident |
|
826 | - * |
|
827 | - */ |
|
823 | + * Check recent aircraft |
|
824 | + * |
|
825 | + * @return String the ident |
|
826 | + * |
|
827 | + */ |
|
828 | 828 | public function checkIdentRecent($ident) |
829 | 829 | { |
830 | 830 | global $globalDBdriver, $globalTimezone; |
@@ -850,14 +850,14 @@ discard block |
||
850 | 850 | $ident_result = $row['fammarine_id']; |
851 | 851 | } |
852 | 852 | return $ident_result; |
853 | - } |
|
853 | + } |
|
854 | 854 | |
855 | 855 | /** |
856 | - * Check recent aircraft by id |
|
857 | - * |
|
858 | - * @return String the ident |
|
859 | - * |
|
860 | - */ |
|
856 | + * Check recent aircraft by id |
|
857 | + * |
|
858 | + * @return String the ident |
|
859 | + * |
|
860 | + */ |
|
861 | 861 | public function checkIdRecent($id) |
862 | 862 | { |
863 | 863 | global $globalDBdriver, $globalTimezone; |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | $ident_result = $row['fammarine_id']; |
884 | 884 | } |
885 | 885 | return $ident_result; |
886 | - } |
|
886 | + } |
|
887 | 887 | |
888 | 888 | /** |
889 | - * Check recent aircraft by mmsi |
|
890 | - * |
|
891 | - * @return String the ident |
|
892 | - * |
|
893 | - */ |
|
889 | + * Check recent aircraft by mmsi |
|
890 | + * |
|
891 | + * @return String the ident |
|
892 | + * |
|
893 | + */ |
|
894 | 894 | public function checkMMSIRecent($mmsi) |
895 | 895 | { |
896 | 896 | global $globalDBdriver, $globalTimezone; |
@@ -916,19 +916,19 @@ discard block |
||
916 | 916 | $ident_result = $row['fammarine_id']; |
917 | 917 | } |
918 | 918 | return $ident_result; |
919 | - } |
|
919 | + } |
|
920 | 920 | |
921 | 921 | /** |
922 | - * Adds a new spotter data |
|
923 | - * |
|
924 | - * @param String $fammarine_id the ID from flightaware |
|
925 | - * @param String $ident the flight ident |
|
926 | - * @param String $aircraft_icao the aircraft type |
|
927 | - * @param String $departure_airport_icao the departure airport |
|
928 | - * @param String $arrival_airport_icao the arrival airport |
|
929 | - * @return String success or false |
|
930 | - * |
|
931 | - */ |
|
922 | + * Adds a new spotter data |
|
923 | + * |
|
924 | + * @param String $fammarine_id the ID from flightaware |
|
925 | + * @param String $ident the flight ident |
|
926 | + * @param String $aircraft_icao the aircraft type |
|
927 | + * @param String $departure_airport_icao the departure airport |
|
928 | + * @param String $arrival_airport_icao the arrival airport |
|
929 | + * @return String success or false |
|
930 | + * |
|
931 | + */ |
|
932 | 932 | 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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1006,10 +1006,10 @@ discard block |
||
1006 | 1006 | if ($typeid == '') $typeid = NULL; |
1007 | 1007 | if ($statusid == '') $statusid = NULL; |
1008 | 1008 | |
1009 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1012 | - $query = ''; |
|
1009 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1012 | + $query = ''; |
|
1013 | 1013 | if ($globalArchive) { |
1014 | 1014 | if ($globalDebug) echo '-- Delete previous data -- '; |
1015 | 1015 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
82 | 82 | } |
83 | 83 | } |
84 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
84 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
87 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
88 | 88 | } |
89 | 89 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
90 | 90 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
91 | 91 | if ($filter_query_where != '') { |
92 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
92 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
93 | 93 | } |
94 | 94 | $filter_query = $filter_query_join.$filter_query_where; |
95 | 95 | return $filter_query; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if ($limit != '') |
113 | 113 | { |
114 | 114 | $limit_array = explode(',', $limit); |
115 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
116 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
115 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
116 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
117 | 117 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
118 | 118 | { |
119 | 119 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 129 | } |
130 | 130 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
131 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
132 | 132 | |
133 | 133 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
134 | 134 | if ($globalDBdriver == 'mysql') { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
139 | 139 | } |
140 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
140 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
141 | 141 | |
142 | 142 | return $spotter_array; |
143 | 143 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
154 | 154 | date_default_timezone_set('UTC'); |
155 | 155 | |
156 | - $filter_query = $this->getFilter($filter,true,true); |
|
156 | + $filter_query = $this->getFilter($filter, true, true); |
|
157 | 157 | |
158 | 158 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
159 | 159 | if ($globalDBdriver == 'mysql') { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | try { |
168 | 168 | $sth = $this->db->prepare($query); |
169 | 169 | $sth->execute(); |
170 | - } catch(PDOException $e) { |
|
170 | + } catch (PDOException $e) { |
|
171 | 171 | echo $e->getMessage(); |
172 | 172 | die; |
173 | 173 | } |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * @return Array the spotter information |
183 | 183 | * |
184 | 184 | */ |
185 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
|
185 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '') |
|
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
188 | 188 | date_default_timezone_set('UTC'); |
189 | 189 | $usecoord = false; |
190 | 190 | if (is_array($coord) && !empty($coord)) { |
191 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
192 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
193 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
194 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
191 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
192 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
193 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
194 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
195 | 195 | $usecoord = true; |
196 | 196 | } |
197 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
198 | - $filter_query = $this->getFilter($filter,true,true); |
|
197 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
198 | + $filter_query = $this->getFilter($filter, true, true); |
|
199 | 199 | |
200 | 200 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
201 | 201 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
202 | 202 | if ($globalDBdriver == 'mysql') { |
203 | 203 | if (isset($globalArchive) && $globalArchive === TRUE) { |
204 | - $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
204 | + $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
205 | 205 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
206 | 206 | if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
207 | 207 | if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ORDER BY fammarine_id, date"; |
216 | 216 | if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
217 | 217 | } else { |
218 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
218 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
219 | 219 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
220 | 220 | if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
221 | 221 | if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | } else { |
227 | 227 | if (isset($globalArchive) && $globalArchive === TRUE) { |
228 | - $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
228 | + $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
229 | 229 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
230 | 230 | if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
231 | 231 | if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | try { |
253 | 253 | $sth = $this->db->prepare($query); |
254 | 254 | $sth->execute($query_values); |
255 | - } catch(PDOException $e) { |
|
255 | + } catch (PDOException $e) { |
|
256 | 256 | echo $e->getMessage(); |
257 | 257 | die; |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function getLiveMarineCount($filter = array()) |
270 | 270 | { |
271 | 271 | global $globalDBdriver, $globalLiveInterval; |
272 | - $filter_query = $this->getFilter($filter,true,true); |
|
272 | + $filter_query = $this->getFilter($filter, true, true); |
|
273 | 273 | |
274 | 274 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
275 | 275 | if ($globalDBdriver == 'mysql') { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | try { |
281 | 281 | $sth = $this->db->prepare($query); |
282 | 282 | $sth->execute(); |
283 | - } catch(PDOException $e) { |
|
283 | + } catch (PDOException $e) { |
|
284 | 284 | echo $e->getMessage(); |
285 | 285 | die; |
286 | 286 | } |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | $filter_query = $this->getFilter($filter); |
304 | 304 | |
305 | 305 | if (is_array($coord)) { |
306 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
307 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
308 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
309 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
306 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
307 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
308 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
309 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
310 | 310 | } else return array(); |
311 | 311 | if ($globalDBdriver == 'mysql') { |
312 | 312 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query; |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
329 | 329 | $Marine = new Marine($this->db); |
330 | 330 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
331 | - $filter_query = $this->getFilter($filter,true,true); |
|
331 | + $filter_query = $this->getFilter($filter, true, true); |
|
332 | 332 | |
333 | 333 | if (is_array($coord)) { |
334 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
335 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
336 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
337 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
334 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
335 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
336 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
337 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
338 | 338 | } else return array(); |
339 | 339 | /* |
340 | 340 | if ($globalDBdriver == 'mysql') { |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | */ |
350 | 350 | if ($globalDBdriver == 'mysql') { |
351 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
352 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
352 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
353 | 353 | FROM marine_live |
354 | 354 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
355 | 355 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
356 | 356 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY date DESC'; |
357 | 357 | } else { |
358 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
358 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
359 | 359 | FROM marine_live |
360 | 360 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
361 | 361 | FROM marine_live l |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | } |
368 | 368 | } else { |
369 | 369 | if (isset($globalArchive) && $globalArchive === TRUE) { |
370 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
370 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
371 | 371 | FROM marine_live |
372 | 372 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
373 | 373 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
374 | 374 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
375 | 375 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY date DESC"; |
376 | 376 | } else { |
377 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
377 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
378 | 378 | FROM marine_live |
379 | 379 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
380 | 380 | FROM marine_live l |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($interval == '1m') |
432 | 432 | { |
433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
434 | - } else if ($interval == '15m'){ |
|
434 | + } else if ($interval == '15m') { |
|
435 | 435 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
436 | 436 | } |
437 | 437 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
440 | 440 | } |
441 | 441 | |
442 | - $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 |
|
442 | + $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 |
|
443 | 443 | WHERE marine_live.latitude <> '' |
444 | 444 | AND marine_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
469 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
@@ -477,14 +477,14 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
480 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
481 | 481 | { |
482 | 482 | $Marine = new Marine($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
485 | 485 | $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'; |
486 | - $date = date('c',$date); |
|
487 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
486 | + $date = date('c', $date); |
|
487 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
488 | 488 | return $spotter_array; |
489 | 489 | } |
490 | 490 | |
@@ -494,14 +494,14 @@ discard block |
||
494 | 494 | * @return Array the spotter information |
495 | 495 | * |
496 | 496 | */ |
497 | - public function getDateLiveMarineDataByMMSI($mmsi,$date) |
|
497 | + public function getDateLiveMarineDataByMMSI($mmsi, $date) |
|
498 | 498 | { |
499 | 499 | $Marine = new Marine($this->db); |
500 | 500 | date_default_timezone_set('UTC'); |
501 | 501 | $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
502 | 502 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi 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'; |
503 | - $date = date('c',$date); |
|
504 | - $spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date)); |
|
503 | + $date = date('c', $date); |
|
504 | + $spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date)); |
|
505 | 505 | return $spotter_array; |
506 | 506 | } |
507 | 507 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | date_default_timezone_set('UTC'); |
518 | 518 | |
519 | 519 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
520 | - $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'; |
|
520 | + $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'; |
|
521 | 521 | |
522 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
522 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
523 | 523 | |
524 | 524 | return $spotter_array; |
525 | 525 | } |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | * @return Array the spotter information |
531 | 531 | * |
532 | 532 | */ |
533 | - public function getDateLiveMarineDataById($id,$date) |
|
533 | + public function getDateLiveMarineDataById($id, $date) |
|
534 | 534 | { |
535 | 535 | $Marine = new Marine($this->db); |
536 | 536 | date_default_timezone_set('UTC'); |
537 | 537 | |
538 | 538 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
539 | - $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'; |
|
540 | - $date = date('c',$date); |
|
541 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
539 | + $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'; |
|
540 | + $date = date('c', $date); |
|
541 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
542 | 542 | |
543 | 543 | return $spotter_array; |
544 | 544 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @return Array the spotter information |
551 | 551 | * |
552 | 552 | */ |
553 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
553 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
554 | 554 | { |
555 | 555 | global $globalDBdriver, $globalLiveInterval; |
556 | 556 | date_default_timezone_set('UTC'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | try { |
570 | 570 | $sth = $this->db->prepare($query); |
571 | 571 | $sth->execute(array(':id' => $id)); |
572 | - } catch(PDOException $e) { |
|
572 | + } catch (PDOException $e) { |
|
573 | 573 | echo $e->getMessage(); |
574 | 574 | die; |
575 | 575 | } |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | { |
588 | 588 | date_default_timezone_set('UTC'); |
589 | 589 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
590 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
590 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
591 | 591 | try { |
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(array(':ident' => $ident)); |
595 | - } catch(PDOException $e) { |
|
595 | + } catch (PDOException $e) { |
|
596 | 596 | echo $e->getMessage(); |
597 | 597 | die; |
598 | 598 | } |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | $sth = $this->db->prepare($query); |
624 | 624 | $sth->execute(); |
625 | - } catch(PDOException $e) { |
|
625 | + } catch (PDOException $e) { |
|
626 | 626 | return "error"; |
627 | 627 | } |
628 | 628 | |
@@ -645,14 +645,14 @@ discard block |
||
645 | 645 | |
646 | 646 | $sth = $this->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error"; |
650 | 650 | } |
651 | 651 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
652 | 652 | $i = 0; |
653 | - $j =0; |
|
653 | + $j = 0; |
|
654 | 654 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | - foreach($all as $row) |
|
655 | + foreach ($all as $row) |
|
656 | 656 | { |
657 | 657 | $i++; |
658 | 658 | $j++; |
@@ -660,9 +660,9 @@ discard block |
||
660 | 660 | if ($globalDebug) echo "."; |
661 | 661 | try { |
662 | 662 | |
663 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
663 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
664 | 664 | $sth->execute(); |
665 | - } catch(PDOException $e) { |
|
665 | + } catch (PDOException $e) { |
|
666 | 666 | return "error"; |
667 | 667 | } |
668 | 668 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | if ($i > 0) { |
674 | 674 | try { |
675 | 675 | |
676 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
676 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error"; |
680 | 680 | } |
681 | 681 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | $sth = $this->db->prepare($query); |
690 | 690 | $sth->execute(); |
691 | - } catch(PDOException $e) { |
|
691 | + } catch (PDOException $e) { |
|
692 | 692 | return "error"; |
693 | 693 | } |
694 | 694 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | public function deleteLiveMarineDataByIdent($ident) |
737 | 737 | { |
738 | 738 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
739 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
739 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
740 | 740 | |
741 | 741 | try { |
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(array(':ident' => $ident)); |
745 | - } catch(PDOException $e) { |
|
745 | + } catch (PDOException $e) { |
|
746 | 746 | return "error"; |
747 | 747 | } |
748 | 748 | |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | public function deleteLiveMarineDataById($id) |
759 | 759 | { |
760 | 760 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
761 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
761 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
762 | 762 | |
763 | 763 | try { |
764 | 764 | |
765 | 765 | $sth = $this->db->prepare($query); |
766 | 766 | $sth->execute(array(':id' => $id)); |
767 | - } catch(PDOException $e) { |
|
767 | + } catch (PDOException $e) { |
|
768 | 768 | return "error"; |
769 | 769 | } |
770 | 770 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function getAllRaces() |
782 | 782 | { |
783 | - $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
783 | + $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
784 | 784 | $sth = $this->db->prepare($query); |
785 | 785 | $sth->execute(); |
786 | 786 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -796,13 +796,13 @@ discard block |
||
796 | 796 | { |
797 | 797 | global $globalDBdriver, $globalTimezone; |
798 | 798 | if ($globalDBdriver == 'mysql') { |
799 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
799 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
800 | 800 | WHERE marine_live.ident = :ident |
801 | 801 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
802 | 802 | AND marine_live.date < UTC_TIMESTAMP()'; |
803 | 803 | $query_data = array(':ident' => $ident); |
804 | 804 | } else { |
805 | - $query = "SELECT marine_live.ident FROM marine_live |
|
805 | + $query = "SELECT marine_live.ident FROM marine_live |
|
806 | 806 | WHERE marine_live.ident = :ident |
807 | 807 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
808 | 808 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | |
812 | 812 | $sth = $this->db->prepare($query); |
813 | 813 | $sth->execute($query_data); |
814 | - $ident_result=''; |
|
815 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | + $ident_result = ''; |
|
815 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
816 | 816 | { |
817 | 817 | $ident_result = $row['ident']; |
818 | 818 | } |
@@ -829,13 +829,13 @@ discard block |
||
829 | 829 | { |
830 | 830 | global $globalDBdriver, $globalTimezone; |
831 | 831 | if ($globalDBdriver == 'mysql') { |
832 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
832 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
833 | 833 | WHERE marine_live.ident = :ident |
834 | 834 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
835 | 835 | // AND marine_live.date < UTC_TIMESTAMP()"; |
836 | 836 | $query_data = array(':ident' => $ident); |
837 | 837 | } else { |
838 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
838 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
839 | 839 | WHERE marine_live.ident = :ident |
840 | 840 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
841 | 841 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | |
845 | 845 | $sth = $this->db->prepare($query); |
846 | 846 | $sth->execute($query_data); |
847 | - $ident_result=''; |
|
848 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
847 | + $ident_result = ''; |
|
848 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
849 | 849 | { |
850 | 850 | $ident_result = $row['fammarine_id']; |
851 | 851 | } |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | { |
863 | 863 | global $globalDBdriver, $globalTimezone; |
864 | 864 | if ($globalDBdriver == 'mysql') { |
865 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
865 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
866 | 866 | WHERE marine_live.fammarine_id = :id |
867 | 867 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
868 | 868 | // AND marine_live.date < UTC_TIMESTAMP()"; |
869 | 869 | $query_data = array(':id' => $id); |
870 | 870 | } else { |
871 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
871 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
872 | 872 | WHERE marine_live.fammarine_id = :id |
873 | 873 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
874 | 874 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | |
878 | 878 | $sth = $this->db->prepare($query); |
879 | 879 | $sth->execute($query_data); |
880 | - $ident_result=''; |
|
881 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | + $ident_result = ''; |
|
881 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
882 | 882 | { |
883 | 883 | $ident_result = $row['fammarine_id']; |
884 | 884 | } |
@@ -895,13 +895,13 @@ discard block |
||
895 | 895 | { |
896 | 896 | global $globalDBdriver, $globalTimezone; |
897 | 897 | if ($globalDBdriver == 'mysql') { |
898 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
898 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
899 | 899 | WHERE marine_live.mmsi = :mmsi |
900 | 900 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
901 | 901 | // AND marine_live.date < UTC_TIMESTAMP()"; |
902 | 902 | $query_data = array(':mmsi' => $mmsi); |
903 | 903 | } else { |
904 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
904 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
905 | 905 | WHERE marine_live.mmsi = :mmsi |
906 | 906 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
907 | 907 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | |
911 | 911 | $sth = $this->db->prepare($query); |
912 | 912 | $sth->execute($query_data); |
913 | - $ident_result=''; |
|
914 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | + $ident_result = ''; |
|
914 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
915 | 915 | { |
916 | 916 | $ident_result = $row['fammarine_id']; |
917 | 917 | } |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @return String success or false |
930 | 930 | * |
931 | 931 | */ |
932 | - 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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
|
932 | + 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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '') |
|
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
935 | 935 | $Common = new Common(); |
@@ -981,33 +981,33 @@ discard block |
||
981 | 981 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
982 | 982 | |
983 | 983 | |
984 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
985 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
986 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
987 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
988 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
990 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
991 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
992 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
993 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
994 | - $typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
995 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
996 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
997 | - $statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
998 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
999 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1000 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1001 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1002 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1003 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1004 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1005 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
984 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
985 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
986 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
987 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
988 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
990 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
991 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
992 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
993 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
994 | + $typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
995 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
996 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
997 | + $statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
998 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
999 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1000 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
1001 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
1002 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
1003 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
1004 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
1005 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
1006 | 1006 | if ($typeid == '') $typeid = NULL; |
1007 | 1007 | if ($statusid == '') $statusid = NULL; |
1008 | 1008 | |
1009 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1009 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1010 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1011 | 1011 | if ($arrival_date == '') $arrival_date = NULL; |
1012 | 1012 | $query = ''; |
1013 | 1013 | if ($globalArchive) { |
@@ -1016,19 +1016,19 @@ discard block |
||
1016 | 1016 | } |
1017 | 1017 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) |
1018 | 1018 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name)'; |
1019 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name); |
|
1019 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name); |
|
1020 | 1020 | try { |
1021 | 1021 | $sth = $this->db->prepare($query); |
1022 | 1022 | $sth->execute($query_values); |
1023 | 1023 | $sth->closeCursor(); |
1024 | - } catch(PDOException $e) { |
|
1024 | + } catch (PDOException $e) { |
|
1025 | 1025 | return "error : ".$e->getMessage(); |
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1029 | 1029 | if ($globalDebug) echo '(Add to Marine archive : '; |
1030 | 1030 | $MarineArchive = new MarineArchive($this->db); |
1031 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name); |
|
1031 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name); |
|
1032 | 1032 | if ($globalDebug) echo $result.')'; |
1033 | 1033 | } |
1034 | 1034 | return "success"; |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | public function getOrderBy() |
1038 | 1038 | { |
1039 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
1039 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
1040 | 1040 | return $orderby; |
1041 | 1041 | } |
1042 | 1042 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -86,8 +90,11 @@ discard block |
||
86 | 90 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | 91 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
88 | 92 | } |
89 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
90 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
93 | + if ($filter_query_where == '' && $where) { |
|
94 | + $filter_query_where = ' WHERE'; |
|
95 | + } elseif ($filter_query_where != '' && $and) { |
|
96 | + $filter_query_where .= ' AND'; |
|
97 | + } |
|
91 | 98 | if ($filter_query_where != '') { |
92 | 99 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
93 | 100 | } |
@@ -128,9 +135,13 @@ discard block |
||
128 | 135 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 136 | } |
130 | 137 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
138 | + if ($orderby_query == '') { |
|
139 | + $orderby_query= ' ORDER BY date DESC'; |
|
140 | + } |
|
132 | 141 | |
133 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
142 | + if (!isset($globalLiveInterval)) { |
|
143 | + $globalLiveInterval = '200'; |
|
144 | + } |
|
134 | 145 | if ($globalDBdriver == 'mysql') { |
135 | 146 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
136 | 147 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -155,7 +166,9 @@ discard block |
||
155 | 166 | |
156 | 167 | $filter_query = $this->getFilter($filter,true,true); |
157 | 168 | |
158 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
169 | + if (!isset($globalLiveInterval)) { |
|
170 | + $globalLiveInterval = '200'; |
|
171 | + } |
|
159 | 172 | if ($globalDBdriver == 'mysql') { |
160 | 173 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
161 | 174 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -197,58 +210,96 @@ discard block |
||
197 | 210 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
198 | 211 | $filter_query = $this->getFilter($filter,true,true); |
199 | 212 | |
200 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
201 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
213 | + if (!isset($globalLiveInterval)) { |
|
214 | + $globalLiveInterval = '200'; |
|
215 | + } |
|
216 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
217 | + $globalMap3DMarinesLimit = '300'; |
|
218 | + } |
|
202 | 219 | if ($globalDBdriver == 'mysql') { |
203 | 220 | if (isset($globalArchive) && $globalArchive === TRUE) { |
204 | 221 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
205 | 222 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
206 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
207 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
223 | + if ($usecoord) { |
|
224 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
225 | + } |
|
226 | + if ($id != '') { |
|
227 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
228 | + } |
|
208 | 229 | $query .= "UNION |
209 | 230 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
210 | 231 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
211 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
212 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
232 | + if ($usecoord) { |
|
233 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
234 | + } |
|
235 | + if ($id != '') { |
|
236 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
237 | + } |
|
213 | 238 | $query .= ") AS marine |
214 | 239 | WHERE latitude <> '0' AND longitude <> '0' |
215 | 240 | ORDER BY fammarine_id, date"; |
216 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
241 | + if ($limit) { |
|
242 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
243 | + } |
|
217 | 244 | } else { |
218 | 245 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
219 | 246 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
220 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
221 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
247 | + if ($usecoord) { |
|
248 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
249 | + } |
|
250 | + if ($id != '') { |
|
251 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
252 | + } |
|
222 | 253 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
223 | 254 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } |
226 | 259 | } else { |
227 | 260 | if (isset($globalArchive) && $globalArchive === TRUE) { |
228 | 261 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
229 | 262 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
230 | - if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
231 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
263 | + if ($usecoord) { |
|
264 | + $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
265 | + } |
|
266 | + if ($id != '') { |
|
267 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
268 | + } |
|
232 | 269 | $query .= "UNION |
233 | 270 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
234 | 271 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
235 | - if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
236 | - if ($id != '') $query .= " OR marine_live.fammarine_id = :id"; |
|
272 | + if ($usecoord) { |
|
273 | + $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
274 | + } |
|
275 | + if ($id != '') { |
|
276 | + $query .= " OR marine_live.fammarine_id = :id"; |
|
277 | + } |
|
237 | 278 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
238 | 279 | $query .= "ORDER BY fammarine_id, date"; |
239 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
280 | + if ($limit) { |
|
281 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
282 | + } |
|
240 | 283 | } else { |
241 | 284 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
242 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
243 | - if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
244 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
286 | + if ($usecoord) { |
|
287 | + $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
288 | + } |
|
289 | + if ($id != '') { |
|
290 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
291 | + } |
|
245 | 292 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
246 | 293 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
247 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
296 | + } |
|
248 | 297 | } |
249 | 298 | } |
250 | 299 | $query_values = array(); |
251 | - if ($id != '') $query_values = array(':id' => $id); |
|
300 | + if ($id != '') { |
|
301 | + $query_values = array(':id' => $id); |
|
302 | + } |
|
252 | 303 | try { |
253 | 304 | $sth = $this->db->prepare($query); |
254 | 305 | $sth->execute($query_values); |
@@ -271,7 +322,9 @@ discard block |
||
271 | 322 | global $globalDBdriver, $globalLiveInterval; |
272 | 323 | $filter_query = $this->getFilter($filter,true,true); |
273 | 324 | |
274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
325 | + if (!isset($globalLiveInterval)) { |
|
326 | + $globalLiveInterval = '200'; |
|
327 | + } |
|
275 | 328 | if ($globalDBdriver == 'mysql') { |
276 | 329 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
277 | 330 | } else { |
@@ -299,7 +352,9 @@ discard block |
||
299 | 352 | { |
300 | 353 | global $globalDBdriver, $globalLiveInterval; |
301 | 354 | $Marine = new Marine($this->db); |
302 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
303 | 358 | $filter_query = $this->getFilter($filter); |
304 | 359 | |
305 | 360 | if (is_array($coord)) { |
@@ -307,7 +362,9 @@ discard block |
||
307 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
308 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
309 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
310 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
311 | 368 | if ($globalDBdriver == 'mysql') { |
312 | 369 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query; |
313 | 370 | } else { |
@@ -327,7 +384,9 @@ discard block |
||
327 | 384 | { |
328 | 385 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
329 | 386 | $Marine = new Marine($this->db); |
330 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
387 | + if (!isset($globalLiveInterval)) { |
|
388 | + $globalLiveInterval = '200'; |
|
389 | + } |
|
331 | 390 | $filter_query = $this->getFilter($filter,true,true); |
332 | 391 | |
333 | 392 | if (is_array($coord)) { |
@@ -335,7 +394,9 @@ discard block |
||
335 | 394 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
336 | 395 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
337 | 396 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
338 | - } else return array(); |
|
397 | + } else { |
|
398 | + return array(); |
|
399 | + } |
|
339 | 400 | /* |
340 | 401 | if ($globalDBdriver == 'mysql') { |
341 | 402 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -558,11 +619,15 @@ discard block |
||
558 | 619 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
559 | 620 | if ($globalDBdriver == 'mysql') { |
560 | 621 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
561 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
622 | + if ($liveinterval) { |
|
623 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
624 | + } |
|
562 | 625 | $query .= ' ORDER BY date'; |
563 | 626 | } else { |
564 | 627 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
565 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
628 | + if ($liveinterval) { |
|
629 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
630 | + } |
|
566 | 631 | $query .= ' ORDER BY date'; |
567 | 632 | } |
568 | 633 | |
@@ -657,7 +722,9 @@ discard block |
||
657 | 722 | $i++; |
658 | 723 | $j++; |
659 | 724 | if ($j == 30) { |
660 | - if ($globalDebug) echo "."; |
|
725 | + if ($globalDebug) { |
|
726 | + echo "."; |
|
727 | + } |
|
661 | 728 | try { |
662 | 729 | |
663 | 730 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -951,7 +1018,9 @@ discard block |
||
951 | 1018 | { |
952 | 1019 | return false; |
953 | 1020 | } |
954 | - } else return ''; |
|
1021 | + } else { |
|
1022 | + return ''; |
|
1023 | + } |
|
955 | 1024 | |
956 | 1025 | if ($longitude != '') |
957 | 1026 | { |
@@ -959,7 +1028,9 @@ discard block |
||
959 | 1028 | { |
960 | 1029 | return false; |
961 | 1030 | } |
962 | - } else return ''; |
|
1031 | + } else { |
|
1032 | + return ''; |
|
1033 | + } |
|
963 | 1034 | |
964 | 1035 | |
965 | 1036 | if ($heading != '') |
@@ -968,7 +1039,9 @@ discard block |
||
968 | 1039 | { |
969 | 1040 | return false; |
970 | 1041 | } |
971 | - } else $heading = 0; |
|
1042 | + } else { |
|
1043 | + $heading = 0; |
|
1044 | + } |
|
972 | 1045 | |
973 | 1046 | if ($groundspeed != '') |
974 | 1047 | { |
@@ -976,9 +1049,13 @@ discard block |
||
976 | 1049 | { |
977 | 1050 | return false; |
978 | 1051 | } |
979 | - } else $groundspeed = 0; |
|
1052 | + } else { |
|
1053 | + $groundspeed = 0; |
|
1054 | + } |
|
980 | 1055 | date_default_timezone_set('UTC'); |
981 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1056 | + if ($date == '') { |
|
1057 | + $date = date("Y-m-d H:i:s", time()); |
|
1058 | + } |
|
982 | 1059 | |
983 | 1060 | |
984 | 1061 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1003,15 +1080,27 @@ discard block |
||
1003 | 1080 | $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
1004 | 1081 | $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
1005 | 1082 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
1006 | - if ($typeid == '') $typeid = NULL; |
|
1007 | - if ($statusid == '') $statusid = NULL; |
|
1083 | + if ($typeid == '') { |
|
1084 | + $typeid = NULL; |
|
1085 | + } |
|
1086 | + if ($statusid == '') { |
|
1087 | + $statusid = NULL; |
|
1088 | + } |
|
1008 | 1089 | |
1009 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1090 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1091 | + $groundspeed = 0; |
|
1092 | + } |
|
1093 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1094 | + $heading = 0; |
|
1095 | + } |
|
1096 | + if ($arrival_date == '') { |
|
1097 | + $arrival_date = NULL; |
|
1098 | + } |
|
1012 | 1099 | $query = ''; |
1013 | 1100 | if ($globalArchive) { |
1014 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1101 | + if ($globalDebug) { |
|
1102 | + echo '-- Delete previous data -- '; |
|
1103 | + } |
|
1015 | 1104 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
1016 | 1105 | } |
1017 | 1106 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) |
@@ -1026,10 +1115,14 @@ discard block |
||
1026 | 1115 | } |
1027 | 1116 | |
1028 | 1117 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1029 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1118 | + if ($globalDebug) { |
|
1119 | + echo '(Add to Marine archive : '; |
|
1120 | + } |
|
1030 | 1121 | $MarineArchive = new MarineArchive($this->db); |
1031 | 1122 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name); |
1032 | - if ($globalDebug) echo $result.')'; |
|
1123 | + if ($globalDebug) { |
|
1124 | + echo $result.')'; |
|
1125 | + } |
|
1033 | 1126 | } |
1034 | 1127 | return "success"; |
1035 | 1128 | } |
@@ -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, $globalLiveInterval; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,104 +105,104 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
|
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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
|
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']; |
|
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
154 | 154 | //$dataFound = true; |
155 | - } |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
172 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
173 | 173 | $Marine = new Marine($this->db); |
174 | 174 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
175 | 175 | unset($Marine); |
176 | - } |
|
176 | + } |
|
177 | + } |
|
177 | 178 | } |
178 | - } |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
192 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
193 | 193 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
196 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | - $Marine = new Marine($this->db); |
|
199 | - $fromsource = NULL; |
|
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | - $Marine->db = null; |
|
198 | + $Marine = new Marine($this->db); |
|
199 | + $fromsource = NULL; |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | + $Marine->db = null; |
|
202 | + } |
|
202 | 203 | } |
203 | - } |
|
204 | 204 | } |
205 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
205 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
206 | 206 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | 207 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
208 | 208 | if (!isset($line['id'])) { |
@@ -210,38 +210,38 @@ discard block |
||
210 | 210 | $this->all_tracked[$id]['forcenew'] = 1; |
211 | 211 | $this->all_tracked[$id]['addedMarine'] = 0; |
212 | 212 | } |
213 | - } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
220 | 220 | } |
221 | 221 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
223 | 223 | } |
224 | 224 | if (isset($line['race_id']) && $line['race_id'] != '') { |
225 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
225 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
226 | 226 | } |
227 | 227 | if (isset($line['race_name']) && $line['race_name'] != '') { |
228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | //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'])) { |
232 | 232 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
233 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
233 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
234 | 234 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
235 | - $timeelapsed = microtime(true); |
|
236 | - $Marine = new Marine($this->db); |
|
237 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
238 | - $Marine->db = null; |
|
235 | + $timeelapsed = microtime(true); |
|
236 | + $Marine = new Marine($this->db); |
|
237 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
238 | + $Marine->db = null; |
|
239 | + } |
|
239 | 240 | } |
240 | - } |
|
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
242 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
242 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
243 | 243 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
244 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
244 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | $Marine = new Marine($this->db); |
247 | 247 | $fromsource = NULL; |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
250 | 250 | $Marine->db = null; |
251 | 251 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
252 | - } |
|
252 | + } |
|
253 | + } |
|
253 | 254 | } |
254 | - } |
|
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
255 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
259 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
259 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
260 | 260 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
261 | - } else { |
|
261 | + } else { |
|
262 | 262 | 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"; |
263 | 263 | 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"; |
264 | 264 | return ''; |
265 | - } |
|
265 | + } |
|
266 | 266 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
267 | 267 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
268 | 268 | return ''; |
@@ -279,33 +279,33 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | if (isset($line['speed'])) { |
282 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
283 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
282 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
283 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
284 | 284 | } 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'])) { |
285 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
286 | - if ($distance > 1000 && $distance < 10000) { |
|
285 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
286 | + if ($distance > 1000 && $distance < 10000) { |
|
287 | 287 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 288 | $speed = $speed*3.6; |
289 | 289 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
290 | 290 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
291 | - } |
|
291 | + } |
|
292 | 292 | } |
293 | 293 | |
294 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | - else unset($timediff); |
|
297 | - if ($this->tmd > 5 || |
|
298 | - !isset($timediff) || |
|
299 | - $timediff > $globalLiveInterval || |
|
300 | - ( |
|
301 | - $timediff > 30 && |
|
302 | - isset($this->all_tracked[$id]['latitude']) && |
|
303 | - isset($this->all_tracked[$id]['longitude']) && |
|
304 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
305 | - ) |
|
306 | - ) { |
|
294 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
295 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | + else unset($timediff); |
|
297 | + if ($this->tmd > 5 || |
|
298 | + !isset($timediff) || |
|
299 | + $timediff > $globalLiveInterval || |
|
300 | + ( |
|
301 | + $timediff > 30 && |
|
302 | + isset($this->all_tracked[$id]['latitude']) && |
|
303 | + isset($this->all_tracked[$id]['longitude']) && |
|
304 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
305 | + ) |
|
306 | + ) { |
|
307 | 307 | 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'])) { |
308 | - 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'])) { |
|
308 | + 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'])) { |
|
309 | 309 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
310 | 310 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 311 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -313,192 +313,192 @@ discard block |
||
313 | 313 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
314 | 314 | $timeelapsed = microtime(true); |
315 | 315 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | - $Marine = new Marine($this->db); |
|
317 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
318 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
319 | - $Marine->db = null; |
|
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
316 | + $Marine = new Marine($this->db); |
|
317 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
318 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
319 | + $Marine->db = null; |
|
320 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
321 | 321 | } |
322 | 322 | $this->tmd = 0; |
323 | 323 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
324 | - } |
|
324 | + } |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | 328 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
329 | 329 | 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') { |
330 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
331 | - $dataFound = true; |
|
332 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
330 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
331 | + $dataFound = true; |
|
332 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
333 | 333 | } |
334 | 334 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
335 | 335 | } |
336 | 336 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
337 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
338 | 338 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
339 | 339 | 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') { |
340 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
341 | - $dataFound = true; |
|
342 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
340 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
341 | + $dataFound = true; |
|
342 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
343 | 343 | } |
344 | 344 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
345 | 345 | } |
346 | 346 | |
347 | - } else if ($globalDebug && $timediff > 20) { |
|
347 | + } else if ($globalDebug && $timediff > 20) { |
|
348 | 348 | $this->tmd = $this->tmd + 1; |
349 | 349 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
350 | 350 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
351 | 351 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
352 | 352 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
353 | - } |
|
353 | + } |
|
354 | 354 | } |
355 | 355 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
356 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['format_source']) && $line['format_source'] != '') { |
360 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
360 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
361 | 361 | } |
362 | 362 | if (isset($line['source_name']) && $line['source_name'] != '') { |
363 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
363 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
373 | - //$dataFound = true; |
|
370 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
373 | + //$dataFound = true; |
|
374 | 374 | } 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']) { |
375 | - $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']); |
|
376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
375 | + $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']); |
|
376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
379 | 379 | } |
380 | 380 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
381 | 381 | |
382 | 382 | |
383 | 383 | |
384 | 384 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
385 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
386 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
387 | - 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'])) { |
|
388 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
385 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
386 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
387 | + 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'])) { |
|
388 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
389 | 389 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
391 | - $timeelapsed = microtime(true); |
|
392 | - $MarineLive = new MarineLive($this->db); |
|
393 | - if (isset($line['id'])) { |
|
390 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
391 | + $timeelapsed = microtime(true); |
|
392 | + $MarineLive = new MarineLive($this->db); |
|
393 | + if (isset($line['id'])) { |
|
394 | 394 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | 395 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
396 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
396 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
397 | 397 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | 398 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
399 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
399 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
400 | 400 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | 401 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
402 | - } else $recent_ident = ''; |
|
403 | - $MarineLive->db=null; |
|
404 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
402 | + } else $recent_ident = ''; |
|
403 | + $MarineLive->db=null; |
|
404 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
406 | 406 | } else $recent_ident = ''; |
407 | - } else { |
|
407 | + } else { |
|
408 | 408 | $recent_ident = ''; |
409 | 409 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
410 | - } |
|
411 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
412 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | - { |
|
410 | + } |
|
411 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
412 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | + { |
|
414 | 414 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
415 | 415 | //adds the spotter data for the archive |
416 | - $highlight = ''; |
|
417 | - 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'))); |
|
418 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
416 | + $highlight = ''; |
|
417 | + 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'))); |
|
418 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
419 | 419 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
420 | - $timeelapsed = microtime(true); |
|
421 | - $Marine = new Marine($this->db); |
|
422 | - $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
423 | - $Marine->db = null; |
|
424 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
420 | + $timeelapsed = microtime(true); |
|
421 | + $Marine = new Marine($this->db); |
|
422 | + $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
423 | + $Marine->db = null; |
|
424 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
425 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
426 | + } |
|
426 | 427 | } |
427 | - } |
|
428 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
428 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
429 | 429 | // Add source stat in DB |
430 | 430 | $Stats = new Stats($this->db); |
431 | 431 | if (!empty($this->stats)) { |
432 | - if ($globalDebug) echo 'Add source stats : '; |
|
433 | - foreach($this->stats as $date => $data) { |
|
432 | + if ($globalDebug) echo 'Add source stats : '; |
|
433 | + foreach($this->stats as $date => $data) { |
|
434 | 434 | foreach($data as $source => $sourced) { |
435 | - //print_r($sourced); |
|
436 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
437 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
438 | - if (isset($sourced['msg'])) { |
|
439 | - if (time() - $sourced['msg']['date'] > 10) { |
|
440 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
441 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
442 | - unset($this->stats[$date][$source]['msg']); |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
446 | - if ($date != date('Y-m-d')) { |
|
447 | - unset($this->stats[$date]); |
|
448 | - } |
|
449 | - } |
|
450 | - if ($globalDebug) echo 'Done'."\n"; |
|
435 | + //print_r($sourced); |
|
436 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
437 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
438 | + if (isset($sourced['msg'])) { |
|
439 | + if (time() - $sourced['msg']['date'] > 10) { |
|
440 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
441 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
442 | + unset($this->stats[$date][$source]['msg']); |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | + if ($date != date('Y-m-d')) { |
|
447 | + unset($this->stats[$date]); |
|
448 | + } |
|
449 | + } |
|
450 | + if ($globalDebug) echo 'Done'."\n"; |
|
451 | 451 | } |
452 | 452 | $Stats->db = null; |
453 | - } |
|
453 | + } |
|
454 | 454 | |
455 | - $this->del(); |
|
455 | + $this->del(); |
|
456 | 456 | //$ignoreImport = false; |
457 | 457 | $this->all_tracked[$id]['addedMarine'] = 1; |
458 | 458 | //print_r($this->all_tracked[$id]); |
459 | 459 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
460 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
461 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
462 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
460 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
461 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
462 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
463 | 463 | $MarineLive = new MarineLive($this->db); |
464 | 464 | $MarineLive->deleteLiveMarineData(); |
465 | 465 | $MarineLive->db=null; |
466 | 466 | if ($globalDebug) echo " Done\n"; |
467 | - } |
|
468 | - $this->last_delete = time(); |
|
467 | + } |
|
468 | + $this->last_delete = time(); |
|
469 | 469 | } |
470 | - } elseif ($recent_ident != '') { |
|
470 | + } elseif ($recent_ident != '') { |
|
471 | 471 | $this->all_tracked[$id]['id'] = $recent_ident; |
472 | 472 | $this->all_tracked[$id]['addedMarine'] = 1; |
473 | 473 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
474 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
474 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
475 | 475 | $Marine = new Marine($this->db); |
476 | 476 | $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']); |
477 | 477 | $Marine->db = null; |
478 | - } |
|
478 | + } |
|
479 | 479 | } |
480 | 480 | |
481 | - } |
|
481 | + } |
|
482 | 482 | } |
483 | - } |
|
484 | - //adds the spotter LIVE data |
|
485 | - if ($globalDebug) { |
|
483 | + } |
|
484 | + //adds the spotter LIVE data |
|
485 | + if ($globalDebug) { |
|
486 | 486 | 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"; |
487 | - } |
|
488 | - $ignoreImport = false; |
|
487 | + } |
|
488 | + $ignoreImport = false; |
|
489 | 489 | |
490 | - if (!$ignoreImport) { |
|
490 | + if (!$ignoreImport) { |
|
491 | 491 | 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'])) { |
492 | 492 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
493 | 493 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
494 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
494 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
495 | 495 | $timeelapsed = microtime(true); |
496 | 496 | $MarineLive = new MarineLive($this->db); |
497 | 497 | $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
498 | 498 | $MarineLive->db = null; |
499 | 499 | if ($globalDebug) echo $result."\n"; |
500 | 500 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
501 | - } |
|
501 | + } |
|
502 | 502 | } |
503 | 503 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
504 | 504 | $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']); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | if ($stats_heading == 16) $stats_heading = 0; |
534 | 534 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
535 | 535 | for ($i=0;$i<=15;$i++) { |
536 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
536 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
537 | 537 | } |
538 | 538 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
539 | 539 | } else { |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | //var_dump($this->stats); |
547 | 547 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
548 | 548 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
549 | - end($this->stats[$current_date][$source]['hist']); |
|
550 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
549 | + end($this->stats[$current_date][$source]['hist']); |
|
550 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
551 | 551 | } else $mini = 0; |
552 | 552 | for ($i=$mini;$i<=$distance;$i+=10) { |
553 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
553 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
554 | 554 | } |
555 | 555 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
556 | 556 | } else { |
@@ -566,24 +566,24 @@ discard block |
||
566 | 566 | |
567 | 567 | |
568 | 568 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
569 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
569 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
570 | 570 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
571 | 571 | $MarineLive = new MarineLive($this->db); |
572 | 572 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
573 | 573 | $MarineLive->db = null; |
574 | 574 | //MarineLive->deleteLiveMarineData(); |
575 | 575 | if ($globalDebug) echo " Done\n"; |
576 | - } |
|
577 | - $this->last_delete_hourly = time(); |
|
576 | + } |
|
577 | + $this->last_delete_hourly = time(); |
|
578 | 578 | } |
579 | 579 | |
580 | - } |
|
581 | - //$ignoreImport = false; |
|
580 | + } |
|
581 | + //$ignoreImport = false; |
|
582 | 582 | } |
583 | 583 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
584 | 584 | if ($send) return $this->all_tracked[$id]; |
585 | - } |
|
585 | + } |
|
586 | + } |
|
586 | 587 | } |
587 | - } |
|
588 | 588 | } |
589 | 589 | ?> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 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']); |
|
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 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
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']); |
|
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 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
107 | + if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi']) || isset($line['id'])) { |
110 | 110 | |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
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' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
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'])); |
|
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 | 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'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 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 | 148 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
149 | 149 | $this->all_tracked[$id]['type'] = $identity['type']; |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
170 | 170 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | 172 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
173 | 173 | $Marine = new Marine($this->db); |
174 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
174 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
175 | 175 | unset($Marine); |
176 | 176 | } |
177 | 177 | } |
@@ -180,24 +180,24 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 192 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
193 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 196 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | 198 | $Marine = new Marine($this->db); |
199 | 199 | $fromsource = NULL; |
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
201 | 201 | $Marine->db = null; |
202 | 202 | } |
203 | 203 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
220 | 220 | } |
221 | 221 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
223 | 223 | } |
224 | 224 | if (isset($line['race_id']) && $line['race_id'] != '') { |
225 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
225 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
226 | 226 | } |
227 | 227 | if (isset($line['race_name']) && $line['race_name'] != '') { |
228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | //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'])) { |
@@ -234,44 +234,44 @@ discard block |
||
234 | 234 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
235 | 235 | $timeelapsed = microtime(true); |
236 | 236 | $Marine = new Marine($this->db); |
237 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
237 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
238 | 238 | $Marine->db = null; |
239 | 239 | } |
240 | 240 | } |
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
242 | 242 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
243 | 243 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
244 | 244 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | $Marine = new Marine($this->db); |
247 | 247 | $fromsource = NULL; |
248 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
248 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
249 | 249 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
250 | 250 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
255 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
256 | 256 | } |
257 | 257 | |
258 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
258 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
259 | 259 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
261 | 261 | } else { |
262 | 262 | 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"; |
263 | 263 | 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"; |
264 | 264 | return ''; |
265 | 265 | } |
266 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
266 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
267 | 267 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
268 | 268 | return ''; |
269 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
269 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
270 | 270 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
271 | 271 | return ''; |
272 | 272 | } elseif (!isset($line['datetime'])) { |
273 | 273 | date_default_timezone_set('UTC'); |
274 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
274 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
275 | 275 | } else { |
276 | 276 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
277 | 277 | return ''; |
@@ -279,20 +279,20 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | if (isset($line['speed'])) { |
282 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
283 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
282 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
283 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
284 | 284 | } 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'])) { |
285 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
285 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
286 | 286 | if ($distance > 1000 && $distance < 10000) { |
287 | 287 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 288 | $speed = $speed*3.6; |
289 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
289 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
290 | 290 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | 294 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
295 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
296 | 296 | else unset($timediff); |
297 | 297 | if ($this->tmd > 5 || |
298 | 298 | !isset($timediff) || |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | $timediff > 30 && |
302 | 302 | isset($this->all_tracked[$id]['latitude']) && |
303 | 303 | isset($this->all_tracked[$id]['longitude']) && |
304 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
304 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
305 | 305 | ) |
306 | 306 | ) { |
307 | 307 | 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'])) { |
308 | - 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'])) { |
|
308 | + 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'])) { |
|
309 | 309 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
310 | 310 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 311 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | $timeelapsed = microtime(true); |
315 | 315 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | 316 | $Marine = new Marine($this->db); |
317 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
317 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
318 | 318 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
319 | 319 | $Marine->db = null; |
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
320 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
321 | 321 | } |
322 | 322 | $this->tmd = 0; |
323 | 323 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -326,55 +326,55 @@ discard block |
||
326 | 326 | |
327 | 327 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | 328 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
329 | - 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') { |
|
329 | + 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') { |
|
330 | 330 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
331 | 331 | $dataFound = true; |
332 | 332 | $this->all_tracked[$id]['time_last_coord'] = time(); |
333 | 333 | } |
334 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
334 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
335 | 335 | } |
336 | 336 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | 337 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
338 | 338 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
339 | - 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') { |
|
339 | + 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') { |
|
340 | 340 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
341 | 341 | $dataFound = true; |
342 | 342 | $this->all_tracked[$id]['time_last_coord'] = time(); |
343 | 343 | } |
344 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
344 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | } else if ($globalDebug && $timediff > 20) { |
348 | 348 | $this->tmd = $this->tmd + 1; |
349 | 349 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
350 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
351 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
350 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
351 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
352 | 352 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | 356 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['format_source']) && $line['format_source'] != '') { |
360 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
360 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
361 | 361 | } |
362 | 362 | if (isset($line['source_name']) && $line['source_name'] != '') { |
363 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
363 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
370 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
372 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
373 | 373 | //$dataFound = true; |
374 | 374 | } 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']) { |
375 | - $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']); |
|
376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
375 | + $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']); |
|
376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
377 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | 378 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
379 | 379 | } |
380 | 380 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
385 | 385 | $this->all_tracked[$id]['lastupdate'] = time(); |
386 | 386 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
387 | - 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'])) { |
|
387 | + 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'])) { |
|
388 | 388 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
389 | 389 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | 390 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -392,37 +392,37 @@ discard block |
||
392 | 392 | $MarineLive = new MarineLive($this->db); |
393 | 393 | if (isset($line['id'])) { |
394 | 394 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
395 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
396 | 396 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
397 | 397 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
398 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
399 | 399 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
400 | 400 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
401 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
402 | 402 | } else $recent_ident = ''; |
403 | - $MarineLive->db=null; |
|
403 | + $MarineLive->db = null; |
|
404 | 404 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
405 | 405 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
406 | 406 | } else $recent_ident = ''; |
407 | 407 | } else { |
408 | 408 | $recent_ident = ''; |
409 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
409 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
410 | 410 | } |
411 | 411 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
412 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
412 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | 413 | { |
414 | 414 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
415 | 415 | //adds the spotter data for the archive |
416 | 416 | $highlight = ''; |
417 | - 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'))); |
|
417 | + 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'))); |
|
418 | 418 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
419 | 419 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
420 | 420 | $timeelapsed = microtime(true); |
421 | 421 | $Marine = new Marine($this->db); |
422 | - $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
422 | + $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'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name']); |
|
423 | 423 | $Marine->db = null; |
424 | 424 | if ($globalDebug && isset($result)) echo $result."\n"; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
425 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -430,15 +430,15 @@ discard block |
||
430 | 430 | $Stats = new Stats($this->db); |
431 | 431 | if (!empty($this->stats)) { |
432 | 432 | if ($globalDebug) echo 'Add source stats : '; |
433 | - foreach($this->stats as $date => $data) { |
|
434 | - foreach($data as $source => $sourced) { |
|
433 | + foreach ($this->stats as $date => $data) { |
|
434 | + foreach ($data as $source => $sourced) { |
|
435 | 435 | //print_r($sourced); |
436 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
437 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
436 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
437 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
438 | 438 | if (isset($sourced['msg'])) { |
439 | 439 | if (time() - $sourced['msg']['date'] > 10) { |
440 | 440 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
441 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
441 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
442 | 442 | unset($this->stats[$date][$source]['msg']); |
443 | 443 | } |
444 | 444 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
463 | 463 | $MarineLive = new MarineLive($this->db); |
464 | 464 | $MarineLive->deleteLiveMarineData(); |
465 | - $MarineLive->db=null; |
|
465 | + $MarineLive->db = null; |
|
466 | 466 | if ($globalDebug) echo " Done\n"; |
467 | 467 | } |
468 | 468 | $this->last_delete = time(); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
474 | 474 | if (isset($globalDaemon) && !$globalDaemon) { |
475 | 475 | $Marine = new Marine($this->db); |
476 | - $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']); |
|
476 | + $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']); |
|
477 | 477 | $Marine->db = null; |
478 | 478 | } |
479 | 479 | } |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | $ignoreImport = false; |
489 | 489 | |
490 | 490 | if (!$ignoreImport) { |
491 | - 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'])) { |
|
491 | + 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'])) { |
|
492 | 492 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
493 | 493 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
494 | 494 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
495 | 495 | $timeelapsed = microtime(true); |
496 | 496 | $MarineLive = new MarineLive($this->db); |
497 | - $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
|
497 | + $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'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name']); |
|
498 | 498 | $MarineLive->db = null; |
499 | 499 | if ($globalDebug) echo $result."\n"; |
500 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
500 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
504 | - $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']); |
|
504 | + $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']); |
|
505 | 505 | } |
506 | 506 | $this->all_tracked[$id]['putinarchive'] = false; |
507 | 507 | |
@@ -520,19 +520,19 @@ discard block |
||
520 | 520 | $latitude = $globalCenterLatitude; |
521 | 521 | $longitude = $globalCenterLongitude; |
522 | 522 | } |
523 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
523 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
524 | 524 | } else { |
525 | 525 | $latitude = $this->source_location[$source]['latitude']; |
526 | 526 | $longitude = $this->source_location[$source]['longitude']; |
527 | 527 | } |
528 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
528 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
529 | 529 | //$stats_heading = $stats_heading%22.5; |
530 | 530 | $stats_heading = round($stats_heading/22.5); |
531 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
531 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
532 | 532 | $current_date = date('Y-m-d'); |
533 | 533 | if ($stats_heading == 16) $stats_heading = 0; |
534 | 534 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
535 | - for ($i=0;$i<=15;$i++) { |
|
535 | + for ($i = 0; $i <= 15; $i++) { |
|
536 | 536 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
537 | 537 | } |
538 | 538 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
548 | 548 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
549 | 549 | end($this->stats[$current_date][$source]['hist']); |
550 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
550 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
551 | 551 | } else $mini = 0; |
552 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
552 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
553 | 553 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
554 | 554 | } |
555 | 555 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | |
562 | 562 | $this->all_tracked[$id]['lastupdate'] = time(); |
563 | 563 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
564 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
564 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
565 | 565 | //$this->del(); |
566 | 566 | |
567 | 567 |
@@ -54,7 +54,9 @@ discard block |
||
54 | 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"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $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 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $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']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $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; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -191,7 +217,9 @@ discard block |
||
191 | 217 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 218 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | 219 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + } |
|
195 | 223 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 224 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 225 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -204,7 +232,9 @@ discard block |
||
204 | 232 | } |
205 | 233 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
206 | 234 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + } |
|
208 | 238 | if (!isset($line['id'])) { |
209 | 239 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
210 | 240 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -213,7 +243,9 @@ discard block |
||
213 | 243 | } |
214 | 244 | } |
215 | 245 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
246 | + if (strtotime($line['arrival_date']) > time()) { |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + } |
|
217 | 249 | } |
218 | 250 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -246,34 +278,49 @@ discard block |
||
246 | 278 | $Marine = new Marine($this->db); |
247 | 279 | $fromsource = NULL; |
248 | 280 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
249 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
281 | + if ($globalDebug && $result != 'success') { |
|
282 | + echo '!!! ERROR : '.$result."\n"; |
|
283 | + } |
|
250 | 284 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + if ($globalDebugTimeElapsed) { |
|
286 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | + } |
|
252 | 288 | } |
253 | 289 | } |
254 | 290 | } |
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
291 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
293 | + } |
|
256 | 294 | } |
257 | 295 | |
258 | 296 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
259 | 297 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
260 | 298 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
261 | 299 | } else { |
262 | - 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"; |
|
263 | - 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"; |
|
300 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
301 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
302 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
303 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
304 | + } |
|
264 | 305 | return ''; |
265 | 306 | } |
266 | 307 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
267 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
310 | + } |
|
268 | 311 | return ''; |
269 | 312 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
270 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
313 | + if ($globalDebug) { |
|
314 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
315 | + } |
|
271 | 316 | return ''; |
272 | 317 | } elseif (!isset($line['datetime'])) { |
273 | 318 | date_default_timezone_set('UTC'); |
274 | 319 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
275 | 320 | } else { |
276 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
321 | + if ($globalDebug) { |
|
322 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
323 | + } |
|
277 | 324 | return ''; |
278 | 325 | } |
279 | 326 | |
@@ -286,14 +333,21 @@ discard block |
||
286 | 333 | if ($distance > 1000 && $distance < 10000) { |
287 | 334 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 335 | $speed = $speed*3.6; |
289 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
290 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
336 | + if ($speed < 1000) { |
|
337 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
341 | + } |
|
291 | 342 | } |
292 | 343 | } |
293 | 344 | |
294 | 345 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | - else unset($timediff); |
|
346 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
347 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
348 | + } else { |
|
349 | + unset($timediff); |
|
350 | + } |
|
297 | 351 | if ($this->tmd > 5 || |
298 | 352 | !isset($timediff) || |
299 | 353 | $timediff > $globalLiveInterval || |
@@ -310,22 +364,32 @@ discard block |
||
310 | 364 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 365 | $this->all_tracked[$id]['putinarchive'] = true; |
312 | 366 | |
313 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
367 | + if ($globalDebug) { |
|
368 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
369 | + } |
|
314 | 370 | $timeelapsed = microtime(true); |
315 | 371 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | 372 | $Marine = new Marine($this->db); |
317 | 373 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
318 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
374 | + if (!empty($all_country)) { |
|
375 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
376 | + } |
|
319 | 377 | $Marine->db = null; |
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
378 | + if ($globalDebugTimeElapsed) { |
|
379 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + } |
|
321 | 381 | } |
322 | 382 | $this->tmd = 0; |
323 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
383 | + if ($globalDebug) { |
|
384 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
385 | + } |
|
324 | 386 | } |
325 | 387 | } |
326 | 388 | |
327 | 389 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
390 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
391 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
392 | + } |
|
329 | 393 | 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') { |
330 | 394 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
331 | 395 | $dataFound = true; |
@@ -334,8 +398,12 @@ discard block |
||
334 | 398 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
335 | 399 | } |
336 | 400 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
338 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
401 | + if ($line['longitude'] > 180) { |
|
402 | + $line['longitude'] = $line['longitude'] - 360; |
|
403 | + } |
|
404 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
405 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
406 | + } |
|
339 | 407 | 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') { |
340 | 408 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
341 | 409 | $dataFound = true; |
@@ -353,7 +421,9 @@ discard block |
||
353 | 421 | } |
354 | 422 | } |
355 | 423 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
424 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
425 | + $dataFound = true; |
|
426 | + } |
|
357 | 427 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
358 | 428 | } |
359 | 429 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -367,15 +437,21 @@ discard block |
||
367 | 437 | } |
368 | 438 | |
369 | 439 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
440 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
441 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
442 | + } |
|
371 | 443 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
372 | 444 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
373 | 445 | //$dataFound = true; |
374 | 446 | } 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']) { |
375 | 447 | $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']); |
376 | 448 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
449 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
450 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
451 | + } |
|
452 | + if ($globalDebug) { |
|
453 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
454 | + } |
|
379 | 455 | } |
380 | 456 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
381 | 457 | |
@@ -387,23 +463,38 @@ discard block |
||
387 | 463 | 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'])) { |
388 | 464 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
389 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
466 | + if ($globalDebug) { |
|
467 | + echo "Check if vessel is already in DB..."; |
|
468 | + } |
|
391 | 469 | $timeelapsed = microtime(true); |
392 | 470 | $MarineLive = new MarineLive($this->db); |
393 | 471 | if (isset($line['id'])) { |
394 | 472 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
473 | + if ($globalDebugTimeElapsed) { |
|
474 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + } |
|
396 | 476 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
397 | 477 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
478 | + if ($globalDebugTimeElapsed) { |
|
479 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
480 | + } |
|
399 | 481 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
400 | 482 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
402 | - } else $recent_ident = ''; |
|
483 | + if ($globalDebugTimeElapsed) { |
|
484 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
485 | + } |
|
486 | + } else { |
|
487 | + $recent_ident = ''; |
|
488 | + } |
|
403 | 489 | $MarineLive->db=null; |
404 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
406 | - } else $recent_ident = ''; |
|
490 | + if ($globalDebug && $recent_ident == '') { |
|
491 | + echo " Not in DB.\n"; |
|
492 | + } elseif ($globalDebug && $recent_ident != '') { |
|
493 | + echo " Already in DB.\n"; |
|
494 | + } |
|
495 | + } else { |
|
496 | + $recent_ident = ''; |
|
497 | + } |
|
407 | 498 | } else { |
408 | 499 | $recent_ident = ''; |
409 | 500 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -411,30 +502,44 @@ discard block |
||
411 | 502 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
412 | 503 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
413 | 504 | { |
414 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
505 | + if ($globalDebug) { |
|
506 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
507 | + } |
|
415 | 508 | //adds the spotter data for the archive |
416 | 509 | $highlight = ''; |
417 | - 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'))); |
|
510 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
511 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
512 | + } |
|
418 | 513 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
419 | 514 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
420 | 515 | $timeelapsed = microtime(true); |
421 | 516 | $Marine = new Marine($this->db); |
422 | 517 | $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
423 | 518 | $Marine->db = null; |
424 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
519 | + if ($globalDebug && isset($result)) { |
|
520 | + echo $result."\n"; |
|
521 | + } |
|
522 | + if ($globalDebugTimeElapsed) { |
|
523 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + } |
|
426 | 525 | } |
427 | 526 | } |
428 | 527 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
429 | 528 | // Add source stat in DB |
430 | 529 | $Stats = new Stats($this->db); |
431 | 530 | if (!empty($this->stats)) { |
432 | - if ($globalDebug) echo 'Add source stats : '; |
|
531 | + if ($globalDebug) { |
|
532 | + echo 'Add source stats : '; |
|
533 | + } |
|
433 | 534 | foreach($this->stats as $date => $data) { |
434 | 535 | foreach($data as $source => $sourced) { |
435 | 536 | //print_r($sourced); |
436 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
437 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
537 | + if (isset($sourced['polar'])) { |
|
538 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
539 | + } |
|
540 | + if (isset($sourced['hist'])) { |
|
541 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
542 | + } |
|
438 | 543 | if (isset($sourced['msg'])) { |
439 | 544 | if (time() - $sourced['msg']['date'] > 10) { |
440 | 545 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -447,7 +552,9 @@ discard block |
||
447 | 552 | unset($this->stats[$date]); |
448 | 553 | } |
449 | 554 | } |
450 | - if ($globalDebug) echo 'Done'."\n"; |
|
555 | + if ($globalDebug) { |
|
556 | + echo 'Done'."\n"; |
|
557 | + } |
|
451 | 558 | } |
452 | 559 | $Stats->db = null; |
453 | 560 | } |
@@ -457,13 +564,17 @@ discard block |
||
457 | 564 | $this->all_tracked[$id]['addedMarine'] = 1; |
458 | 565 | //print_r($this->all_tracked[$id]); |
459 | 566 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
460 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
567 | + if ($globalDebug) { |
|
568 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
569 | + } |
|
461 | 570 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
462 | 571 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
463 | 572 | $MarineLive = new MarineLive($this->db); |
464 | 573 | $MarineLive->deleteLiveMarineData(); |
465 | 574 | $MarineLive->db=null; |
466 | - if ($globalDebug) echo " Done\n"; |
|
575 | + if ($globalDebug) { |
|
576 | + echo " Done\n"; |
|
577 | + } |
|
467 | 578 | } |
468 | 579 | $this->last_delete = time(); |
469 | 580 | } |
@@ -489,15 +600,21 @@ discard block |
||
489 | 600 | |
490 | 601 | if (!$ignoreImport) { |
491 | 602 | 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'])) { |
492 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
603 | + if ($globalDebug) { |
|
604 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
605 | + } |
|
493 | 606 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
494 | 607 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
495 | 608 | $timeelapsed = microtime(true); |
496 | 609 | $MarineLive = new MarineLive($this->db); |
497 | 610 | $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']); |
498 | 611 | $MarineLive->db = null; |
499 | - if ($globalDebug) echo $result."\n"; |
|
500 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
612 | + if ($globalDebug) { |
|
613 | + echo $result."\n"; |
|
614 | + } |
|
615 | + if ($globalDebugTimeElapsed) { |
|
616 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
617 | + } |
|
501 | 618 | } |
502 | 619 | } |
503 | 620 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -509,7 +626,9 @@ discard block |
||
509 | 626 | |
510 | 627 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
511 | 628 | $source = $this->all_tracked[$id]['source_name']; |
512 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
629 | + if ($source == '') { |
|
630 | + $source = $this->all_tracked[$id]['format_source']; |
|
631 | + } |
|
513 | 632 | if (!isset($this->source_location[$source])) { |
514 | 633 | $Location = new Source($this->db); |
515 | 634 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -530,7 +649,9 @@ discard block |
||
530 | 649 | $stats_heading = round($stats_heading/22.5); |
531 | 650 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
532 | 651 | $current_date = date('Y-m-d'); |
533 | - if ($stats_heading == 16) $stats_heading = 0; |
|
652 | + if ($stats_heading == 16) { |
|
653 | + $stats_heading = 0; |
|
654 | + } |
|
534 | 655 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
535 | 656 | for ($i=0;$i<=15;$i++) { |
536 | 657 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -548,7 +669,9 @@ discard block |
||
548 | 669 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
549 | 670 | end($this->stats[$current_date][$source]['hist']); |
550 | 671 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
551 | - } else $mini = 0; |
|
672 | + } else { |
|
673 | + $mini = 0; |
|
674 | + } |
|
552 | 675 | for ($i=$mini;$i<=$distance;$i+=10) { |
553 | 676 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
554 | 677 | } |
@@ -560,19 +683,27 @@ discard block |
||
560 | 683 | |
561 | 684 | |
562 | 685 | $this->all_tracked[$id]['lastupdate'] = time(); |
563 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
564 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
686 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
687 | + $send = true; |
|
688 | + } |
|
689 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
690 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
691 | + } |
|
565 | 692 | //$this->del(); |
566 | 693 | |
567 | 694 | |
568 | 695 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
569 | 696 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
570 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
697 | + if ($globalDebug) { |
|
698 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
699 | + } |
|
571 | 700 | $MarineLive = new MarineLive($this->db); |
572 | 701 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
573 | 702 | $MarineLive->db = null; |
574 | 703 | //MarineLive->deleteLiveMarineData(); |
575 | - if ($globalDebug) echo " Done\n"; |
|
704 | + if ($globalDebug) { |
|
705 | + echo " Done\n"; |
|
706 | + } |
|
576 | 707 | } |
577 | 708 | $this->last_delete_hourly = time(); |
578 | 709 | } |
@@ -581,7 +712,9 @@ discard block |
||
581 | 712 | //$ignoreImport = false; |
582 | 713 | } |
583 | 714 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
584 | - if ($send) return $this->all_tracked[$id]; |
|
715 | + if ($send) { |
|
716 | + return $this->all_tracked[$id]; |
|
717 | + } |
|
585 | 718 | } |
586 | 719 | } |
587 | 720 | } |
@@ -50,30 +50,30 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | function quaternionrotate($heading, $attitude = 0, $bank = 0) { |
53 | - // Assuming the angles are in radians. |
|
54 | - $c1 = cos($heading/2); |
|
55 | - $s1 = sin($heading/2); |
|
56 | - $c2 = cos($attitude/2); |
|
57 | - $s2 = sin($attitude/2); |
|
58 | - $c3 = cos($bank/2); |
|
59 | - $s3 = sin($bank/2); |
|
60 | - $c1c2 = $c1*$c2; |
|
61 | - $s1s2 = $s1*$s2; |
|
62 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
63 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
64 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
53 | + // Assuming the angles are in radians. |
|
54 | + $c1 = cos($heading/2); |
|
55 | + $s1 = sin($heading/2); |
|
56 | + $c2 = cos($attitude/2); |
|
57 | + $s2 = sin($attitude/2); |
|
58 | + $c3 = cos($bank/2); |
|
59 | + $s3 = sin($bank/2); |
|
60 | + $c1c2 = $c1*$c2; |
|
61 | + $s1s2 = $s1*$s2; |
|
62 | + $w =$c1c2*$c3 - $s1s2*$s3; |
|
63 | + $x =$c1c2*$s3 + $s1s2*$c3; |
|
64 | + $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | + $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | + return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
67 | 67 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | if (isset($_GET['download'])) { |
73 | - if ($_GET['download'] == "true") |
|
74 | - { |
|
73 | + if ($_GET['download'] == "true") |
|
74 | + { |
|
75 | 75 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
76 | - } |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | header('Content-Type: text/javascript'); |
79 | 79 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
185 | 185 | $coord = explode(',',$_GET['coord']); |
186 | 186 | if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
187 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
187 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
188 | 188 | $coord = array(); |
189 | 189 | } |
190 | 190 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
209 | 209 | $coord = explode(',',$_GET['coord']); |
210 | 210 | if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
211 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
211 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
212 | 212 | $coord = array(); |
213 | 213 | } |
214 | 214 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
230 | 230 | $coord = explode(',',$_GET['coord']); |
231 | 231 | if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
232 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
232 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
|
233 | 233 | $coord = array(); |
234 | 234 | } |
235 | 235 | } |
@@ -350,10 +350,10 @@ discard block |
||
350 | 350 | $image = "images/placeholder_thumb.png"; |
351 | 351 | } |
352 | 352 | |
353 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
354 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
355 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
356 | - if ($prev_flightaware_id != $id) { |
|
353 | + if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
354 | + elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
355 | + elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
356 | + if ($prev_flightaware_id != $id) { |
|
357 | 357 | if ($prev_flightaware_id != '') { |
358 | 358 | /* |
359 | 359 | if ($nblatlong == 1) { |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
450 | 450 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
451 | 451 | } else $aircraft_shadow = ''; |
452 | - $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
452 | + $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
453 | 453 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) { |
454 | 454 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
455 | 455 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
481 | 481 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
482 | 482 | } |
483 | - $output .= '},'; |
|
483 | + $output .= '},'; |
|
484 | 484 | } elseif (isset($modelsdb[$aircraft_icao]) && $aircraft_icao != '') { |
485 | 485 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_icao].'","scale" : '.$scale.',"minimumPixelSize": '.$minimumpixelsize.''; |
486 | 486 | $output .= ',"heightReference": "'.$heightrelative.'"'; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
489 | 489 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
490 | 490 | } |
491 | - $output .= '},'; |
|
491 | + $output .= '},'; |
|
492 | 492 | } elseif ($aircraft_icao != '') { |
493 | 493 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
494 | 494 | if (isset($aircraft_info[0]['engine_type'])) { |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $s3 = sin($bank/2); |
60 | 60 | $c1c2 = $c1*$c2; |
61 | 61 | $s1s2 = $s1*$s2; |
62 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
63 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
64 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
62 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
63 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
64 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
67 | 67 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
68 | 68 | |
69 | 69 | } |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | $min = false; |
85 | 85 | $allhistory = false; |
86 | 86 | $filter['source'] = array(); |
87 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
88 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
89 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
90 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
91 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
92 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
93 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
94 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
95 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
96 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
97 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
87 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
88 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
90 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
91 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
92 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
93 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
94 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
95 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
96 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
97 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
98 | 98 | /* |
99 | 99 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
100 | 100 | $min = true; |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $from_archive = true; |
142 | 142 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
143 | 143 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
144 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
145 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
146 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
147 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
148 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
144 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
145 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
146 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
148 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
149 | 149 | if ($tracker) { |
150 | - $spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate,$enddate,$filter); |
|
150 | + $spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate, $enddate, $filter); |
|
151 | 151 | } elseif ($marine) { |
152 | - $spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate,$enddate,$filter); |
|
152 | + $spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate, $enddate, $filter); |
|
153 | 153 | } else { |
154 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
154 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
155 | 155 | } |
156 | 156 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
157 | 157 | $from_archive = true; |
@@ -168,36 +168,36 @@ discard block |
||
168 | 168 | } |
169 | 169 | $enddate = $_COOKIE['archive_end']; |
170 | 170 | $enddateinitial = $_COOKIE['archive_end']; |
171 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
172 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
173 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
171 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
172 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
173 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
174 | 174 | //echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
175 | 175 | if ($tracker) { |
176 | - $spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate,$enddate,$filter); |
|
176 | + $spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate, $enddate, $filter); |
|
177 | 177 | } elseif ($marine) { |
178 | - $spotter_array = $MarineArchive->getMinLiveMarineData($begindate,$enddate,$filter); |
|
178 | + $spotter_array = $MarineArchive->getMinLiveMarineData($begindate, $enddate, $filter); |
|
179 | 179 | } else { |
180 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
180 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
181 | 181 | } |
182 | 182 | } elseif ($tracker) { |
183 | 183 | $coord = array(); |
184 | 184 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
185 | - $coord = explode(',',$_GET['coord']); |
|
186 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
185 | + $coord = explode(',', $_GET['coord']); |
|
186 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
187 | 187 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
188 | 188 | $coord = array(); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | $previous_filter = $filter; |
192 | 192 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackTracker']) && $_COOKIE['MapTrackTracker'] != '')) { |
193 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrackTracker'])); |
|
194 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true); |
|
193 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrackTracker'])); |
|
194 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true); |
|
195 | 195 | /* |
196 | 196 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) { |
197 | 197 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true,$_COOKIE['MapTrack']); |
198 | 198 | */ |
199 | 199 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
200 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true); |
|
200 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true); |
|
201 | 201 | } else { |
202 | 202 | $spotter_array = array(); |
203 | 203 | } |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | $coord = array(); |
207 | 207 | //if (isset($_GET['coord']) && $_GET['coord'] != '') { |
208 | 208 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
209 | - $coord = explode(',',$_GET['coord']); |
|
210 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
209 | + $coord = explode(',', $_GET['coord']); |
|
210 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
211 | 211 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
212 | 212 | $coord = array(); |
213 | 213 | } |
214 | 214 | } |
215 | 215 | $previous_filter = $filter; |
216 | 216 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) { |
217 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrackMarine'])); |
|
218 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true); |
|
217 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrackMarine'])); |
|
218 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true); |
|
219 | 219 | } elseif (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '' && !empty($coord)) { |
220 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true,$_COOKIE['MapTrack']); |
|
220 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true, $_COOKIE['MapTrack']); |
|
221 | 221 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
222 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true); |
|
222 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true); |
|
223 | 223 | } else { |
224 | 224 | $spotter_array = array(); |
225 | 225 | } |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | } else { |
228 | 228 | $coord = array(); |
229 | 229 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
230 | - $coord = explode(',',$_GET['coord']); |
|
231 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
230 | + $coord = explode(',', $_GET['coord']); |
|
231 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
232 | 232 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
233 | 233 | $coord = array(); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | $previous_filter = $filter; |
237 | 237 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) { |
238 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrack'])); |
|
239 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
238 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrack'])); |
|
239 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
240 | 240 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) { |
241 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true,$_COOKIE['MapTrack']); |
|
241 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true, $_COOKIE['MapTrack']); |
|
242 | 242 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
243 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
243 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
244 | 244 | } else { |
245 | 245 | $spotter_array = array(); |
246 | 246 | } |
@@ -250,19 +250,19 @@ discard block |
||
250 | 250 | if (!empty($spotter_array) && isset($coord)) { |
251 | 251 | if ($tracker) { |
252 | 252 | if (isset($_GET['archive'])) { |
253 | - $flightcnt = $TrackerArchive->getLiveTrackerCount($begindate,$enddate,$filter); |
|
253 | + $flightcnt = $TrackerArchive->getLiveTrackerCount($begindate, $enddate, $filter); |
|
254 | 254 | } else { |
255 | 255 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
256 | 256 | } |
257 | 257 | } elseif ($marine) { |
258 | 258 | if (isset($_GET['archive'])) { |
259 | - $flightcnt = $MarineArchive->getLiveMarineCount($begindate,$enddate,$filter); |
|
259 | + $flightcnt = $MarineArchive->getLiveMarineCount($begindate, $enddate, $filter); |
|
260 | 260 | } else { |
261 | 261 | $flightcnt = $MarineLive->getLiveMarineCount($filter); |
262 | 262 | } |
263 | 263 | } else { |
264 | 264 | if (isset($_GET['archive'])) { |
265 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
265 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
266 | 266 | } else { |
267 | 267 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
268 | 268 | } |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | if ($flightcnt == '') $flightcnt = 0; |
271 | 271 | } else $flightcnt = 0; |
272 | 272 | |
273 | -$sqltime = round(microtime(true)-$begintime,2); |
|
273 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
274 | 274 | $minitime = time(); |
275 | 275 | $minitracktime_begin = time(); |
276 | 276 | $minitracktime = $minitracktime_begin; |
277 | 277 | $maxitime = 0; |
278 | -$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT); |
|
278 | +$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT); |
|
279 | 279 | $modelsdb = array(); |
280 | 280 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
281 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
282 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
283 | - if (isset($row[1]) ){ |
|
281 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
282 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
283 | + if (isset($row[1])) { |
|
284 | 284 | $model = $row[0]; |
285 | 285 | $modelsdb[$model] = $row[1]; |
286 | 286 | } |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | $modelsdb2 = array(); |
292 | 292 | if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) { |
293 | - if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) { |
|
294 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
295 | - if (isset($row[1]) ){ |
|
293 | + if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) { |
|
294 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
295 | + if (isset($row[1])) { |
|
296 | 296 | $model = $row[0]; |
297 | 297 | $glb = $row[1]; |
298 | 298 | if (isset($row[2])) { |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if (!empty($spotter_array) && is_array($spotter_array)) |
339 | 339 | { |
340 | 340 | $nblatlong = 0; |
341 | - foreach($spotter_array as $spotter_item) |
|
341 | + foreach ($spotter_array as $spotter_item) |
|
342 | 342 | { |
343 | 343 | $j++; |
344 | 344 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | } |
393 | 393 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
394 | 394 | if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",'; |
395 | - if (isset($spotter_item['ident'])) $output.= '"ident": "'.$spotter_item['ident'].'",'; |
|
395 | + if (isset($spotter_item['ident'])) $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
396 | 396 | if ($tracker) { |
397 | 397 | if (isset($spotter_item['type'])) $output .= '"tracker_type": "'.$spotter_item['type'].'",'; |
398 | - $output.= '"type": "tracker"'; |
|
398 | + $output .= '"type": "tracker"'; |
|
399 | 399 | } elseif ($marine) { |
400 | 400 | if (isset($spotter_item['type'])) $output .= '"marine_type": "'.$spotter_item['type'].'",'; |
401 | - $output.= '"type": "marine"'; |
|
401 | + $output .= '"type": "marine"'; |
|
402 | 402 | } else { |
403 | 403 | if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) { |
404 | 404 | $aircraft_icao = $spotter_item['aircraft_icao']; |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | if (isset($airline_icao)) { |
413 | 413 | $imagefile = $aircraft_icao.'-'.$airline_icao.'.png'; |
414 | 414 | if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) { |
415 | - $output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
415 | + $output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | } |
419 | 419 | //if ($ident != '') $output.= '"ident": "'.$ident.'",'; |
420 | 420 | } |
421 | - $output.= '"gltf2": %gltf2%,'; |
|
422 | - $output.= '"type": "flight"'; |
|
421 | + $output .= '"gltf2": %gltf2%,'; |
|
422 | + $output .= '"type": "flight"'; |
|
423 | 423 | } |
424 | 424 | $output .= '},'; |
425 | 425 | |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | $output .= '},'; |
791 | 791 | } |
792 | 792 | } |
793 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
794 | - else $output = str_replace('%onground%','false',$output); |
|
793 | + if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output); |
|
794 | + else $output = str_replace('%onground%', 'false', $output); |
|
795 | 795 | |
796 | 796 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
797 | 797 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
808 | 808 | if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']); |
809 | 809 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
810 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
810 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
811 | 811 | $output .= $spotter_item['longitude'].', '; |
812 | 812 | $output .= $spotter_item['latitude']; |
813 | 813 | $prevlong = $spotter_item['longitude']; |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
836 | 836 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
837 | 837 | } else { |
838 | - $nblatlong = $nblatlong+1; |
|
839 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
838 | + $nblatlong = $nblatlong + 1; |
|
839 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
840 | 840 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
841 | 841 | if ($spotter_item['ground_speed'] == 0) { |
842 | 842 | $output .= $prevlong.', '; |
@@ -877,26 +877,26 @@ discard block |
||
877 | 877 | $output .= ']'; |
878 | 878 | if (isset($globalArchive) && $globalArchive === TRUE) { |
879 | 879 | if (isset($begindateinitial)) { |
880 | - $output = str_replace('%minitime%',date("c",$begindateinitial),$output); |
|
881 | - } elseif ((time()-$globalLiveInterval) > $minitime) { |
|
882 | - if (time()-$globalLiveInterval > $maxitime) { |
|
883 | - $output = str_replace('%minitime%',date("c",$maxitime),$output); |
|
880 | + $output = str_replace('%minitime%', date("c", $begindateinitial), $output); |
|
881 | + } elseif ((time() - $globalLiveInterval) > $minitime) { |
|
882 | + if (time() - $globalLiveInterval > $maxitime) { |
|
883 | + $output = str_replace('%minitime%', date("c", $maxitime), $output); |
|
884 | 884 | } else { |
885 | - $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
885 | + $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
886 | 886 | } |
887 | 887 | } |
888 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
888 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
889 | 889 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) { |
890 | - $output = str_replace('%minitime%',date("c",$minitracktime),$output); |
|
890 | + $output = str_replace('%minitime%', date("c", $minitracktime), $output); |
|
891 | 891 | } else { |
892 | - $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
892 | + $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
893 | 893 | } |
894 | 894 | if (isset($enddateinitial)) { |
895 | - $output = str_replace('%maxitime%',date("c",$enddateinitial),$output); |
|
895 | + $output = str_replace('%maxitime%', date("c", $enddateinitial), $output); |
|
896 | 896 | } else { |
897 | - $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
897 | + $output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
898 | 898 | } |
899 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
900 | -else $output = str_replace('%gltf2%','false',$output); |
|
899 | +if ($gltf2) $output = str_replace('%gltf2%', 'true', $output); |
|
900 | +else $output = str_replace('%gltf2%', 'false', $output); |
|
901 | 901 | print $output; |
902 | 902 | ?> |