@@ -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(); |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * Gets all the spotter information based on the latest data entry |
|
133 | - * |
|
134 | - * @return Array the spotter information |
|
135 | - * |
|
136 | - */ |
|
132 | + * Gets all the spotter information based on the latest data entry |
|
133 | + * |
|
134 | + * @return Array the spotter information |
|
135 | + * |
|
136 | + */ |
|
137 | 137 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
138 | 138 | { |
139 | 139 | global $globalDBdriver, $globalLiveInterval; |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
179 | - * Gets Minimal Live Spotter data |
|
180 | - * |
|
181 | - * @return Array the spotter information |
|
182 | - * |
|
183 | - */ |
|
179 | + * Gets Minimal Live Spotter data |
|
180 | + * |
|
181 | + * @return Array the spotter information |
|
182 | + * |
|
183 | + */ |
|
184 | 184 | public function getMinLiveSpotterData($filter = array()) |
185 | 185 | { |
186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | - * Gets Minimal Live Spotter data since xx seconds |
|
221 | - * |
|
222 | - * @return Array the spotter information |
|
223 | - * |
|
224 | - */ |
|
220 | + * Gets Minimal Live Spotter data since xx seconds |
|
221 | + * |
|
222 | + * @return Array the spotter information |
|
223 | + * |
|
224 | + */ |
|
225 | 225 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
226 | 226 | { |
227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Gets number of latest data entry |
|
306 | - * |
|
307 | - * @return String number of entry |
|
308 | - * |
|
309 | - */ |
|
305 | + * Gets number of latest data entry |
|
306 | + * |
|
307 | + * @return String number of entry |
|
308 | + * |
|
309 | + */ |
|
310 | 310 | public function getLiveSpotterCount($filter = array()) |
311 | 311 | { |
312 | 312 | global $globalDBdriver, $globalLiveInterval; |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
336 | - * Gets all the spotter information based on the latest data entry and coord |
|
337 | - * |
|
338 | - * @return Array the spotter information |
|
339 | - * |
|
340 | - */ |
|
336 | + * Gets all the spotter information based on the latest data entry and coord |
|
337 | + * |
|
338 | + * @return Array the spotter information |
|
339 | + * |
|
340 | + */ |
|
341 | 341 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
342 | 342 | { |
343 | 343 | global $globalDBdriver, $globalLiveInterval; |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | - * Gets all the spotter information based on the latest data entry and coord |
|
366 | - * |
|
367 | - * @return Array the spotter information |
|
368 | - * |
|
369 | - */ |
|
365 | + * Gets all the spotter information based on the latest data entry and coord |
|
366 | + * |
|
367 | + * @return Array the spotter information |
|
368 | + * |
|
369 | + */ |
|
370 | 370 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
371 | 371 | { |
372 | 372 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -431,11 +431,11 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
434 | - * Gets all the spotter information based on a user's latitude and longitude |
|
435 | - * |
|
436 | - * @return Array the spotter information |
|
437 | - * |
|
438 | - */ |
|
434 | + * Gets all the spotter information based on a user's latitude and longitude |
|
435 | + * |
|
436 | + * @return Array the spotter information |
|
437 | + * |
|
438 | + */ |
|
439 | 439 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
440 | 440 | { |
441 | 441 | $Spotter = new Spotter($this->db); |
@@ -445,98 +445,98 @@ discard block |
||
445 | 445 | return false; |
446 | 446 | } |
447 | 447 | } |
448 | - if ($lng != '') |
|
449 | - { |
|
450 | - if (!is_numeric($lng)) |
|
451 | - { |
|
452 | - return false; |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - if ($radius != '') |
|
457 | - { |
|
458 | - if (!is_numeric($radius)) |
|
459 | - { |
|
460 | - return false; |
|
461 | - } |
|
462 | - } |
|
448 | + if ($lng != '') |
|
449 | + { |
|
450 | + if (!is_numeric($lng)) |
|
451 | + { |
|
452 | + return false; |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + if ($radius != '') |
|
457 | + { |
|
458 | + if (!is_numeric($radius)) |
|
459 | + { |
|
460 | + return false; |
|
461 | + } |
|
462 | + } |
|
463 | 463 | $additional_query = ''; |
464 | - if ($interval != '') |
|
465 | - { |
|
466 | - if (!is_string($interval)) |
|
467 | - { |
|
468 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
469 | - return false; |
|
470 | - } else { |
|
471 | - if ($interval == '1m') |
|
472 | - { |
|
473 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
474 | - } else if ($interval == '15m'){ |
|
475 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
476 | - } |
|
477 | - } |
|
478 | - } else { |
|
479 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
480 | - } |
|
481 | - |
|
482 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
464 | + if ($interval != '') |
|
465 | + { |
|
466 | + if (!is_string($interval)) |
|
467 | + { |
|
468 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
469 | + return false; |
|
470 | + } else { |
|
471 | + if ($interval == '1m') |
|
472 | + { |
|
473 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
474 | + } else if ($interval == '15m'){ |
|
475 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
476 | + } |
|
477 | + } |
|
478 | + } else { |
|
479 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
480 | + } |
|
481 | + |
|
482 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
483 | 483 | WHERE spotter_live.latitude <> '' |
484 | 484 | AND spotter_live.longitude <> '' |
485 | 485 | ".$additional_query." |
486 | 486 | HAVING distance < :radius |
487 | 487 | ORDER BY distance"; |
488 | 488 | |
489 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
490 | 490 | |
491 | - return $spotter_array; |
|
492 | - } |
|
491 | + return $spotter_array; |
|
492 | + } |
|
493 | 493 | |
494 | 494 | |
495 | - /** |
|
496 | - * Gets all the spotter information based on a particular callsign |
|
497 | - * |
|
498 | - * @return Array the spotter information |
|
499 | - * |
|
500 | - */ |
|
495 | + /** |
|
496 | + * Gets all the spotter information based on a particular callsign |
|
497 | + * |
|
498 | + * @return Array the spotter information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getLastLiveSpotterDataByIdent($ident) |
502 | 502 | { |
503 | 503 | $Spotter = new Spotter($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
507 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
508 | 508 | |
509 | 509 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
513 | 513 | |
514 | - /** |
|
515 | - * Gets all the spotter information based on a particular callsign |
|
516 | - * |
|
517 | - * @return Array the spotter information |
|
518 | - * |
|
519 | - */ |
|
514 | + /** |
|
515 | + * Gets all the spotter information based on a particular callsign |
|
516 | + * |
|
517 | + * @return Array the spotter information |
|
518 | + * |
|
519 | + */ |
|
520 | 520 | public function getDateLiveSpotterDataByIdent($ident,$date) |
521 | 521 | { |
522 | 522 | $Spotter = new Spotter($this->db); |
523 | 523 | date_default_timezone_set('UTC'); |
524 | 524 | |
525 | 525 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
526 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
527 | 527 | |
528 | - $date = date('c',$date); |
|
528 | + $date = date('c',$date); |
|
529 | 529 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
530 | 530 | |
531 | 531 | return $spotter_array; |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Gets last spotter information based on a particular callsign |
|
536 | - * |
|
537 | - * @return Array the spotter information |
|
538 | - * |
|
539 | - */ |
|
534 | + /** |
|
535 | + * Gets last spotter information based on a particular callsign |
|
536 | + * |
|
537 | + * @return Array the spotter information |
|
538 | + * |
|
539 | + */ |
|
540 | 540 | public function getLastLiveSpotterDataById($id) |
541 | 541 | { |
542 | 542 | $Spotter = new Spotter($this->db); |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | return $spotter_array; |
548 | 548 | } |
549 | 549 | |
550 | - /** |
|
551 | - * Gets last spotter information based on a particular callsign |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
550 | + /** |
|
551 | + * Gets last spotter information based on a particular callsign |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | 556 | public function getDateLiveSpotterDataById($id,$date) |
557 | 557 | { |
558 | 558 | $Spotter = new Spotter($this->db); |
@@ -565,21 +565,21 @@ discard block |
||
565 | 565 | return $spotter_array; |
566 | 566 | } |
567 | 567 | |
568 | - /** |
|
569 | - * Gets altitude information based on a particular callsign |
|
570 | - * |
|
571 | - * @return Array the spotter information |
|
572 | - * |
|
573 | - */ |
|
568 | + /** |
|
569 | + * Gets altitude information based on a particular callsign |
|
570 | + * |
|
571 | + * @return Array the spotter information |
|
572 | + * |
|
573 | + */ |
|
574 | 574 | public function getAltitudeLiveSpotterDataByIdent($ident) |
575 | 575 | { |
576 | 576 | |
577 | 577 | date_default_timezone_set('UTC'); |
578 | 578 | |
579 | 579 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
580 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
580 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
581 | 581 | |
582 | - try { |
|
582 | + try { |
|
583 | 583 | |
584 | 584 | $sth = $this->db->prepare($query); |
585 | 585 | $sth->execute(array(':ident' => $ident)); |
@@ -592,12 +592,12 @@ discard block |
||
592 | 592 | return $spotter_array; |
593 | 593 | } |
594 | 594 | |
595 | - /** |
|
596 | - * Gets all the spotter information based on a particular id |
|
597 | - * |
|
598 | - * @return Array the spotter information |
|
599 | - * |
|
600 | - */ |
|
595 | + /** |
|
596 | + * Gets all the spotter information based on a particular id |
|
597 | + * |
|
598 | + * @return Array the spotter information |
|
599 | + * |
|
600 | + */ |
|
601 | 601 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
602 | 602 | { |
603 | 603 | global $globalDBdriver, $globalLiveInterval; |
@@ -625,18 +625,18 @@ discard block |
||
625 | 625 | return $spotter_array; |
626 | 626 | } |
627 | 627 | |
628 | - /** |
|
629 | - * Gets all the spotter information based on a particular ident |
|
630 | - * |
|
631 | - * @return Array the spotter information |
|
632 | - * |
|
633 | - */ |
|
628 | + /** |
|
629 | + * Gets all the spotter information based on a particular ident |
|
630 | + * |
|
631 | + * @return Array the spotter information |
|
632 | + * |
|
633 | + */ |
|
634 | 634 | public function getAllLiveSpotterDataByIdent($ident) |
635 | 635 | { |
636 | 636 | date_default_timezone_set('UTC'); |
637 | 637 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
638 | 638 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
639 | - try { |
|
639 | + try { |
|
640 | 640 | |
641 | 641 | $sth = $this->db->prepare($query); |
642 | 642 | $sth->execute(array(':ident' => $ident)); |
@@ -650,23 +650,23 @@ discard block |
||
650 | 650 | |
651 | 651 | |
652 | 652 | /** |
653 | - * Deletes all info in the table |
|
654 | - * |
|
655 | - * @return String success or false |
|
656 | - * |
|
657 | - */ |
|
653 | + * Deletes all info in the table |
|
654 | + * |
|
655 | + * @return String success or false |
|
656 | + * |
|
657 | + */ |
|
658 | 658 | public function deleteLiveSpotterData() |
659 | 659 | { |
660 | 660 | global $globalDBdriver; |
661 | 661 | if ($globalDBdriver == 'mysql') { |
662 | 662 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
663 | 663 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
664 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
664 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
665 | 665 | } else { |
666 | 666 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
667 | 667 | } |
668 | 668 | |
669 | - try { |
|
669 | + try { |
|
670 | 670 | |
671 | 671 | $sth = $this->db->prepare($query); |
672 | 672 | $sth->execute(); |
@@ -678,18 +678,18 @@ discard block |
||
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
681 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
682 | - * |
|
683 | - * @return String success or false |
|
684 | - * |
|
685 | - */ |
|
681 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
682 | + * |
|
683 | + * @return String success or false |
|
684 | + * |
|
685 | + */ |
|
686 | 686 | public function deleteLiveSpotterDataNotUpdated() |
687 | 687 | { |
688 | 688 | global $globalDBdriver, $globalDebug; |
689 | 689 | if ($globalDBdriver == 'mysql') { |
690 | 690 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
691 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
692 | - try { |
|
691 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
692 | + try { |
|
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute(); |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | return "error"; |
698 | 698 | } |
699 | 699 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
700 | - $i = 0; |
|
701 | - $j =0; |
|
700 | + $i = 0; |
|
701 | + $j =0; |
|
702 | 702 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
703 | 703 | foreach($all as $row) |
704 | 704 | { |
@@ -706,20 +706,20 @@ discard block |
||
706 | 706 | $j++; |
707 | 707 | if ($j == 30) { |
708 | 708 | if ($globalDebug) echo "."; |
709 | - try { |
|
709 | + try { |
|
710 | 710 | |
711 | 711 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
712 | 712 | $sth->execute(); |
713 | 713 | } catch(PDOException $e) { |
714 | 714 | return "error"; |
715 | 715 | } |
716 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
717 | - $j = 0; |
|
716 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
717 | + $j = 0; |
|
718 | 718 | } |
719 | 719 | $query_delete .= "'".$row['flightaware_id']."',"; |
720 | 720 | } |
721 | 721 | if ($i > 0) { |
722 | - try { |
|
722 | + try { |
|
723 | 723 | |
724 | 724 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
725 | 725 | $sth->execute(); |
@@ -730,9 +730,9 @@ discard block |
||
730 | 730 | return "success"; |
731 | 731 | } elseif ($globalDBdriver == 'pgsql') { |
732 | 732 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
733 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
734 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
735 | - try { |
|
733 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
734 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
735 | + try { |
|
736 | 736 | |
737 | 737 | $sth = $this->db->prepare($query); |
738 | 738 | $sth->execute(); |
@@ -776,17 +776,17 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | - * Deletes all info in the table for an ident |
|
780 | - * |
|
781 | - * @return String success or false |
|
782 | - * |
|
783 | - */ |
|
779 | + * Deletes all info in the table for an ident |
|
780 | + * |
|
781 | + * @return String success or false |
|
782 | + * |
|
783 | + */ |
|
784 | 784 | public function deleteLiveSpotterDataByIdent($ident) |
785 | 785 | { |
786 | 786 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
787 | 787 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
788 | 788 | |
789 | - try { |
|
789 | + try { |
|
790 | 790 | |
791 | 791 | $sth = $this->db->prepare($query); |
792 | 792 | $sth->execute(array(':ident' => $ident)); |
@@ -798,17 +798,17 @@ discard block |
||
798 | 798 | } |
799 | 799 | |
800 | 800 | /** |
801 | - * Deletes all info in the table for an id |
|
802 | - * |
|
803 | - * @return String success or false |
|
804 | - * |
|
805 | - */ |
|
801 | + * Deletes all info in the table for an id |
|
802 | + * |
|
803 | + * @return String success or false |
|
804 | + * |
|
805 | + */ |
|
806 | 806 | public function deleteLiveSpotterDataById($id) |
807 | 807 | { |
808 | 808 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
809 | 809 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
810 | 810 | |
811 | - try { |
|
811 | + try { |
|
812 | 812 | |
813 | 813 | $sth = $this->db->prepare($query); |
814 | 814 | $sth->execute(array(':id' => $id)); |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | |
822 | 822 | |
823 | 823 | /** |
824 | - * Gets the aircraft ident within the last hour |
|
825 | - * |
|
826 | - * @return String the ident |
|
827 | - * |
|
828 | - */ |
|
824 | + * Gets the aircraft ident within the last hour |
|
825 | + * |
|
826 | + * @return String the ident |
|
827 | + * |
|
828 | + */ |
|
829 | 829 | public function getIdentFromLastHour($ident) |
830 | 830 | { |
831 | 831 | global $globalDBdriver, $globalTimezone; |
@@ -851,14 +851,14 @@ discard block |
||
851 | 851 | $ident_result = $row['ident']; |
852 | 852 | } |
853 | 853 | return $ident_result; |
854 | - } |
|
854 | + } |
|
855 | 855 | |
856 | 856 | /** |
857 | - * Check recent aircraft |
|
858 | - * |
|
859 | - * @return String the ident |
|
860 | - * |
|
861 | - */ |
|
857 | + * Check recent aircraft |
|
858 | + * |
|
859 | + * @return String the ident |
|
860 | + * |
|
861 | + */ |
|
862 | 862 | public function checkIdentRecent($ident) |
863 | 863 | { |
864 | 864 | global $globalDBdriver, $globalTimezone; |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | $ident_result = $row['flightaware_id']; |
885 | 885 | } |
886 | 886 | return $ident_result; |
887 | - } |
|
887 | + } |
|
888 | 888 | |
889 | 889 | /** |
890 | - * Check recent aircraft by id |
|
891 | - * |
|
892 | - * @return String the ident |
|
893 | - * |
|
894 | - */ |
|
890 | + * Check recent aircraft by id |
|
891 | + * |
|
892 | + * @return String the ident |
|
893 | + * |
|
894 | + */ |
|
895 | 895 | public function checkIdRecent($id) |
896 | 896 | { |
897 | 897 | global $globalDBdriver, $globalTimezone; |
@@ -917,14 +917,14 @@ discard block |
||
917 | 917 | $ident_result = $row['flightaware_id']; |
918 | 918 | } |
919 | 919 | return $ident_result; |
920 | - } |
|
920 | + } |
|
921 | 921 | |
922 | 922 | /** |
923 | - * Check recent aircraft by ModeS |
|
924 | - * |
|
925 | - * @return String the ModeS |
|
926 | - * |
|
927 | - */ |
|
923 | + * Check recent aircraft by ModeS |
|
924 | + * |
|
925 | + * @return String the ModeS |
|
926 | + * |
|
927 | + */ |
|
928 | 928 | public function checkModeSRecent($modes) |
929 | 929 | { |
930 | 930 | global $globalDBdriver, $globalTimezone; |
@@ -951,19 +951,19 @@ discard block |
||
951 | 951 | $ident_result = $row['flightaware_id']; |
952 | 952 | } |
953 | 953 | return $ident_result; |
954 | - } |
|
954 | + } |
|
955 | 955 | |
956 | 956 | /** |
957 | - * Adds a new spotter data |
|
958 | - * |
|
959 | - * @param String $flightaware_id the ID from flightaware |
|
960 | - * @param String $ident the flight ident |
|
961 | - * @param String $aircraft_icao the aircraft type |
|
962 | - * @param String $departure_airport_icao the departure airport |
|
963 | - * @param String $arrival_airport_icao the arrival airport |
|
964 | - * @return String success or false |
|
965 | - * |
|
966 | - */ |
|
957 | + * Adds a new spotter data |
|
958 | + * |
|
959 | + * @param String $flightaware_id the ID from flightaware |
|
960 | + * @param String $ident the flight ident |
|
961 | + * @param String $aircraft_icao the aircraft type |
|
962 | + * @param String $departure_airport_icao the departure airport |
|
963 | + * @param String $arrival_airport_icao the arrival airport |
|
964 | + * @return String success or false |
|
965 | + * |
|
966 | + */ |
|
967 | 967 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
968 | 968 | { |
969 | 969 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1106,10 +1106,10 @@ discard block |
||
1106 | 1106 | $arrival_airport_country = ''; |
1107 | 1107 | |
1108 | 1108 | |
1109 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1110 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1111 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1112 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1109 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1111 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1112 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1113 | 1113 | |
1114 | 1114 | $query = ''; |
1115 | 1115 | if ($globalArchive) { |
@@ -1130,10 +1130,10 @@ discard block |
||
1130 | 1130 | return "error : ".$e->getMessage(); |
1131 | 1131 | } |
1132 | 1132 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1133 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1134 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1135 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1136 | - if ($globalDebug) echo $result.')'; |
|
1133 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1134 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1135 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1136 | + if ($globalDebug) echo $result.')'; |
|
1137 | 1137 | } elseif ($globalDebug && $putinarchive !== true) { |
1138 | 1138 | echo '(Not adding to archive)'; |
1139 | 1139 | } elseif ($globalDebug && $noarchive === true) { |
@@ -405,17 +405,17 @@ discard block |
||
405 | 405 | } |
406 | 406 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
407 | 407 | } else $all = array(); |
408 | - if (empty($all)) { |
|
409 | - $Spotter = new Spotter($this->db); |
|
410 | - $filters = array(); |
|
408 | + if (empty($all)) { |
|
409 | + $Spotter = new Spotter($this->db); |
|
410 | + $filters = array(); |
|
411 | 411 | $filters = array('year' => $year,'month' => $month); |
412 | - if ($filter_name != '') { |
|
413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
412 | + if ($filter_name != '') { |
|
413 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
414 | 414 | } |
415 | 415 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
416 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
417 | - } |
|
418 | - return $all; |
|
416 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
417 | + } |
|
418 | + return $all; |
|
419 | 419 | } |
420 | 420 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
421 | 421 | global $globalStatsFilters; |
@@ -1612,7 +1612,7 @@ discard block |
||
1612 | 1612 | return "error : ".$e->getMessage(); |
1613 | 1613 | } |
1614 | 1614 | } |
1615 | - /* |
|
1615 | + /* |
|
1616 | 1616 | public function getStatsSource($date,$stats_type = '') { |
1617 | 1617 | if ($stats_type == '') { |
1618 | 1618 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -2574,8 +2574,8 @@ discard block |
||
2574 | 2574 | } |
2575 | 2575 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
2576 | 2576 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
2577 | - foreach ($alldata as $number) { |
|
2578 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2577 | + foreach ($alldata as $number) { |
|
2578 | + $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2579 | 2579 | } |
2580 | 2580 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
2581 | 2581 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -151,44 +151,44 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * Gets all the spotter information based on a particular callsign |
|
156 | - * |
|
157 | - * @return Array the spotter information |
|
158 | - * |
|
159 | - */ |
|
160 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
161 | - { |
|
154 | + /** |
|
155 | + * Gets all the spotter information based on a particular callsign |
|
156 | + * |
|
157 | + * @return Array the spotter information |
|
158 | + * |
|
159 | + */ |
|
160 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
161 | + { |
|
162 | 162 | $Spotter = new Spotter($this->db); |
163 | - date_default_timezone_set('UTC'); |
|
163 | + date_default_timezone_set('UTC'); |
|
164 | 164 | |
165 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
166 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
165 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
166 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
168 | 168 | |
169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
169 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | 170 | |
171 | - return $spotter_array; |
|
172 | - } |
|
171 | + return $spotter_array; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | - /** |
|
176 | - * Gets last the spotter information based on a particular id |
|
177 | - * |
|
178 | - * @return Array the spotter information |
|
179 | - * |
|
180 | - */ |
|
181 | - public function getLastArchiveSpotterDataById($id) |
|
182 | - { |
|
183 | - $Spotter = new Spotter($this->db); |
|
184 | - date_default_timezone_set('UTC'); |
|
185 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
186 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
187 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
175 | + /** |
|
176 | + * Gets last the spotter information based on a particular id |
|
177 | + * |
|
178 | + * @return Array the spotter information |
|
179 | + * |
|
180 | + */ |
|
181 | + public function getLastArchiveSpotterDataById($id) |
|
182 | + { |
|
183 | + $Spotter = new Spotter($this->db); |
|
184 | + date_default_timezone_set('UTC'); |
|
185 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
186 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
187 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
189 | 189 | |
190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
191 | - /* |
|
191 | + /* |
|
192 | 192 | try { |
193 | 193 | $Connection = new Connection(); |
194 | 194 | $sth = Connection->$db->prepare($query); |
@@ -198,122 +198,122 @@ discard block |
||
198 | 198 | } |
199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
200 | 200 | */ |
201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | - |
|
203 | - return $spotter_array; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Gets all the spotter information based on a particular id |
|
208 | - * |
|
209 | - * @return Array the spotter information |
|
210 | - * |
|
211 | - */ |
|
212 | - public function getAllArchiveSpotterDataById($id) |
|
201 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | + |
|
203 | + return $spotter_array; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Gets all the spotter information based on a particular id |
|
208 | + * |
|
209 | + * @return Array the spotter information |
|
210 | + * |
|
211 | + */ |
|
212 | + public function getAllArchiveSpotterDataById($id) |
|
213 | 213 | { |
214 | - date_default_timezone_set('UTC'); |
|
215 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
214 | + date_default_timezone_set('UTC'); |
|
215 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
217 | 217 | |
218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
219 | 219 | |
220 | - try { |
|
221 | - $sth = $this->db->prepare($query); |
|
222 | - $sth->execute(array(':id' => $id)); |
|
223 | - } catch(PDOException $e) { |
|
224 | - echo $e->getMessage(); |
|
225 | - die; |
|
226 | - } |
|
227 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | - |
|
229 | - return $spotter_array; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Gets coordinate & time spotter information based on a particular id |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
238 | - public function getCoordArchiveSpotterDataById($id) |
|
239 | - { |
|
240 | - date_default_timezone_set('UTC'); |
|
241 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
220 | + try { |
|
221 | + $sth = $this->db->prepare($query); |
|
222 | + $sth->execute(array(':id' => $id)); |
|
223 | + } catch(PDOException $e) { |
|
224 | + echo $e->getMessage(); |
|
225 | + die; |
|
226 | + } |
|
227 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + |
|
229 | + return $spotter_array; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Gets coordinate & time spotter information based on a particular id |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | + public function getCoordArchiveSpotterDataById($id) |
|
239 | + { |
|
240 | + date_default_timezone_set('UTC'); |
|
241 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
243 | 243 | |
244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
245 | 245 | |
246 | - try { |
|
247 | - $sth = $this->db->prepare($query); |
|
248 | - $sth->execute(array(':id' => $id)); |
|
249 | - } catch(PDOException $e) { |
|
250 | - echo $e->getMessage(); |
|
251 | - die; |
|
252 | - } |
|
253 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
246 | + try { |
|
247 | + $sth = $this->db->prepare($query); |
|
248 | + $sth->execute(array(':id' => $id)); |
|
249 | + } catch(PDOException $e) { |
|
250 | + echo $e->getMessage(); |
|
251 | + die; |
|
252 | + } |
|
253 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
254 | 254 | |
255 | - return $spotter_array; |
|
256 | - } |
|
255 | + return $spotter_array; |
|
256 | + } |
|
257 | 257 | |
258 | 258 | |
259 | - /** |
|
260 | - * Gets altitude information based on a particular callsign |
|
261 | - * |
|
262 | - * @return Array the spotter information |
|
263 | - * |
|
264 | - */ |
|
265 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
266 | - { |
|
259 | + /** |
|
260 | + * Gets altitude information based on a particular callsign |
|
261 | + * |
|
262 | + * @return Array the spotter information |
|
263 | + * |
|
264 | + */ |
|
265 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
266 | + { |
|
267 | 267 | |
268 | - date_default_timezone_set('UTC'); |
|
268 | + date_default_timezone_set('UTC'); |
|
269 | 269 | |
270 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
270 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
272 | 272 | |
273 | - try { |
|
274 | - $sth = $this->db->prepare($query); |
|
275 | - $sth->execute(array(':ident' => $ident)); |
|
276 | - } catch(PDOException $e) { |
|
277 | - echo $e->getMessage(); |
|
278 | - die; |
|
279 | - } |
|
280 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | + try { |
|
274 | + $sth = $this->db->prepare($query); |
|
275 | + $sth->execute(array(':ident' => $ident)); |
|
276 | + } catch(PDOException $e) { |
|
277 | + echo $e->getMessage(); |
|
278 | + die; |
|
279 | + } |
|
280 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
281 | 281 | |
282 | - return $spotter_array; |
|
283 | - } |
|
282 | + return $spotter_array; |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Gets altitude information based on a particular id |
|
287 | - * |
|
288 | - * @return Array the spotter information |
|
289 | - * |
|
290 | - */ |
|
291 | - public function getAltitudeArchiveSpotterDataById($id) |
|
292 | - { |
|
285 | + /** |
|
286 | + * Gets altitude information based on a particular id |
|
287 | + * |
|
288 | + * @return Array the spotter information |
|
289 | + * |
|
290 | + */ |
|
291 | + public function getAltitudeArchiveSpotterDataById($id) |
|
292 | + { |
|
293 | 293 | |
294 | - date_default_timezone_set('UTC'); |
|
294 | + date_default_timezone_set('UTC'); |
|
295 | 295 | |
296 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
296 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
298 | 298 | |
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute(array(':id' => $id)); |
|
302 | - } catch(PDOException $e) { |
|
303 | - echo $e->getMessage(); |
|
304 | - die; |
|
305 | - } |
|
306 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute(array(':id' => $id)); |
|
302 | + } catch(PDOException $e) { |
|
303 | + echo $e->getMessage(); |
|
304 | + die; |
|
305 | + } |
|
306 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
307 | 307 | |
308 | - return $spotter_array; |
|
309 | - } |
|
308 | + return $spotter_array; |
|
309 | + } |
|
310 | 310 | |
311 | - /** |
|
312 | - * Gets altitude & speed information based on a particular id |
|
313 | - * |
|
314 | - * @return Array the spotter information |
|
315 | - * |
|
316 | - */ |
|
311 | + /** |
|
312 | + * Gets altitude & speed information based on a particular id |
|
313 | + * |
|
314 | + * @return Array the spotter information |
|
315 | + * |
|
316 | + */ |
|
317 | 317 | public function getAltitudeSpeedArchiveSpotterDataById($id) |
318 | 318 | { |
319 | 319 | date_default_timezone_set('UTC'); |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | return $spotter_array; |
331 | 331 | } |
332 | 332 | |
333 | - /** |
|
334 | - * Gets altitude information based on a particular callsign |
|
335 | - * |
|
336 | - * @return Array the spotter information |
|
337 | - * |
|
338 | - */ |
|
333 | + /** |
|
334 | + * Gets altitude information based on a particular callsign |
|
335 | + * |
|
336 | + * @return Array the spotter information |
|
337 | + * |
|
338 | + */ |
|
339 | 339 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
340 | 340 | { |
341 | 341 | date_default_timezone_set('UTC'); |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | |
356 | 356 | |
357 | 357 | |
358 | - /** |
|
359 | - * Gets all the archive spotter information |
|
360 | - * |
|
361 | - * @return Array the spotter information |
|
362 | - * |
|
363 | - */ |
|
358 | + /** |
|
359 | + * Gets all the archive spotter information |
|
360 | + * |
|
361 | + * @return Array the spotter information |
|
362 | + * |
|
363 | + */ |
|
364 | 364 | public function getSpotterArchiveData($ident,$flightaware_id,$date) |
365 | 365 | { |
366 | 366 | $Spotter = new Spotter($this->db); |
@@ -388,34 +388,34 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | - * Gets Minimal Live Spotter data |
|
392 | - * |
|
393 | - * @return Array the spotter information |
|
394 | - * |
|
395 | - */ |
|
396 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
397 | - { |
|
398 | - global $globalDBdriver, $globalLiveInterval; |
|
399 | - date_default_timezone_set('UTC'); |
|
400 | - |
|
401 | - $filter_query = ''; |
|
402 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
403 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
404 | - } |
|
405 | - // Use spotter_output also ? |
|
406 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
407 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
408 | - } |
|
409 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
410 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
411 | - } |
|
412 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
413 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
414 | - } |
|
391 | + * Gets Minimal Live Spotter data |
|
392 | + * |
|
393 | + * @return Array the spotter information |
|
394 | + * |
|
395 | + */ |
|
396 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
397 | + { |
|
398 | + global $globalDBdriver, $globalLiveInterval; |
|
399 | + date_default_timezone_set('UTC'); |
|
400 | + |
|
401 | + $filter_query = ''; |
|
402 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
403 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
404 | + } |
|
405 | + // Use spotter_output also ? |
|
406 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
407 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
408 | + } |
|
409 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
410 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
411 | + } |
|
412 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
413 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
414 | + } |
|
415 | 415 | |
416 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
417 | - if ($globalDBdriver == 'mysql') { |
|
418 | - /* |
|
416 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
417 | + if ($globalDBdriver == 'mysql') { |
|
418 | + /* |
|
419 | 419 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
420 | 420 | FROM spotter_archive |
421 | 421 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -434,56 +434,56 @@ discard block |
||
434 | 434 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
435 | 435 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
436 | 436 | '.$filter_query.' ORDER BY flightaware_id'; |
437 | - } else { |
|
438 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
439 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
437 | + } else { |
|
438 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
439 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
440 | 440 | FROM spotter_archive |
441 | 441 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
442 | 442 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
443 | 443 | '.$filter_query.' ORDER BY flightaware_id'; |
444 | - } |
|
445 | - //echo $query; |
|
446 | - try { |
|
447 | - $sth = $this->db->prepare($query); |
|
448 | - $sth->execute(); |
|
449 | - } catch(PDOException $e) { |
|
450 | - echo $e->getMessage(); |
|
451 | - die; |
|
452 | - } |
|
453 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
444 | + } |
|
445 | + //echo $query; |
|
446 | + try { |
|
447 | + $sth = $this->db->prepare($query); |
|
448 | + $sth->execute(); |
|
449 | + } catch(PDOException $e) { |
|
450 | + echo $e->getMessage(); |
|
451 | + die; |
|
452 | + } |
|
453 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
454 | 454 | |
455 | - return $spotter_array; |
|
456 | - } |
|
455 | + return $spotter_array; |
|
456 | + } |
|
457 | 457 | |
458 | 458 | /** |
459 | - * Gets Minimal Live Spotter data |
|
460 | - * |
|
461 | - * @return Array the spotter information |
|
462 | - * |
|
463 | - */ |
|
464 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
465 | - { |
|
466 | - global $globalDBdriver, $globalLiveInterval; |
|
467 | - date_default_timezone_set('UTC'); |
|
468 | - |
|
469 | - $filter_query = ''; |
|
470 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
471 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
472 | - } |
|
473 | - // Should use spotter_output also ? |
|
474 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
475 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
476 | - } |
|
477 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
478 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
479 | - } |
|
480 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
481 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
482 | - } |
|
459 | + * Gets Minimal Live Spotter data |
|
460 | + * |
|
461 | + * @return Array the spotter information |
|
462 | + * |
|
463 | + */ |
|
464 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
465 | + { |
|
466 | + global $globalDBdriver, $globalLiveInterval; |
|
467 | + date_default_timezone_set('UTC'); |
|
468 | + |
|
469 | + $filter_query = ''; |
|
470 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
471 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
472 | + } |
|
473 | + // Should use spotter_output also ? |
|
474 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
475 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
476 | + } |
|
477 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
478 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
479 | + } |
|
480 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
481 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
482 | + } |
|
483 | 483 | |
484 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
485 | - if ($globalDBdriver == 'mysql') { |
|
486 | - /* |
|
484 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
485 | + if ($globalDBdriver == 'mysql') { |
|
486 | + /* |
|
487 | 487 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
488 | 488 | FROM spotter_archive |
489 | 489 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -494,95 +494,95 @@ discard block |
||
494 | 494 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
495 | 495 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
496 | 496 | |
497 | - } else { |
|
498 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
499 | - /* |
|
497 | + } else { |
|
498 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
499 | + /* |
|
500 | 500 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
501 | 501 | FROM spotter_archive_output |
502 | 502 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
503 | 503 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
505 | 505 | */ |
506 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
506 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
507 | 507 | FROM spotter_archive_output |
508 | 508 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
509 | 509 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
510 | 510 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
511 | 511 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
512 | 512 | |
513 | - } |
|
514 | - //echo $query; |
|
515 | - try { |
|
516 | - $sth = $this->db->prepare($query); |
|
517 | - $sth->execute(); |
|
518 | - } catch(PDOException $e) { |
|
519 | - echo $e->getMessage(); |
|
520 | - die; |
|
521 | - } |
|
522 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
513 | + } |
|
514 | + //echo $query; |
|
515 | + try { |
|
516 | + $sth = $this->db->prepare($query); |
|
517 | + $sth->execute(); |
|
518 | + } catch(PDOException $e) { |
|
519 | + echo $e->getMessage(); |
|
520 | + die; |
|
521 | + } |
|
522 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
523 | 523 | |
524 | - return $spotter_array; |
|
525 | - } |
|
524 | + return $spotter_array; |
|
525 | + } |
|
526 | 526 | |
527 | 527 | /** |
528 | - * Gets count Live Spotter data |
|
529 | - * |
|
530 | - * @return Array the spotter information |
|
531 | - * |
|
532 | - */ |
|
533 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
534 | - { |
|
535 | - global $globalDBdriver, $globalLiveInterval; |
|
536 | - date_default_timezone_set('UTC'); |
|
537 | - |
|
538 | - $filter_query = ''; |
|
539 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
540 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
541 | - } |
|
542 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
543 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
544 | - } |
|
545 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
546 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
547 | - } |
|
548 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
549 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
550 | - } |
|
528 | + * Gets count Live Spotter data |
|
529 | + * |
|
530 | + * @return Array the spotter information |
|
531 | + * |
|
532 | + */ |
|
533 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
534 | + { |
|
535 | + global $globalDBdriver, $globalLiveInterval; |
|
536 | + date_default_timezone_set('UTC'); |
|
551 | 537 | |
552 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
553 | - if ($globalDBdriver == 'mysql') { |
|
538 | + $filter_query = ''; |
|
539 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
540 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
541 | + } |
|
542 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
543 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
544 | + } |
|
545 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
546 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
547 | + } |
|
548 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
549 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
550 | + } |
|
551 | + |
|
552 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
553 | + if ($globalDBdriver == 'mysql') { |
|
554 | 554 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
555 | 555 | FROM spotter_archive l |
556 | 556 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
557 | - } else { |
|
557 | + } else { |
|
558 | 558 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
559 | - } |
|
560 | - //echo $query; |
|
561 | - try { |
|
562 | - $sth = $this->db->prepare($query); |
|
563 | - $sth->execute(); |
|
564 | - } catch(PDOException $e) { |
|
565 | - echo $e->getMessage(); |
|
566 | - die; |
|
567 | - } |
|
559 | + } |
|
560 | + //echo $query; |
|
561 | + try { |
|
562 | + $sth = $this->db->prepare($query); |
|
563 | + $sth->execute(); |
|
564 | + } catch(PDOException $e) { |
|
565 | + echo $e->getMessage(); |
|
566 | + die; |
|
567 | + } |
|
568 | 568 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
569 | 569 | $sth->closeCursor(); |
570 | - return $result['nb']; |
|
570 | + return $result['nb']; |
|
571 | 571 | |
572 | - } |
|
572 | + } |
|
573 | 573 | |
574 | 574 | |
575 | 575 | |
576 | 576 | // Spotter_Archive_output |
577 | 577 | |
578 | - /** |
|
579 | - * Gets all the spotter information |
|
580 | - * |
|
581 | - * @return Array the spotter information |
|
582 | - * |
|
583 | - */ |
|
584 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
585 | - { |
|
578 | + /** |
|
579 | + * Gets all the spotter information |
|
580 | + * |
|
581 | + * @return Array the spotter information |
|
582 | + * |
|
583 | + */ |
|
584 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
585 | + { |
|
586 | 586 | global $globalTimezone, $globalDBdriver; |
587 | 587 | require_once(dirname(__FILE__).'/class.Translation.php'); |
588 | 588 | $Translation = new Translation($this->db); |
@@ -596,159 +596,159 @@ discard block |
||
596 | 596 | $filter_query = $this->getFilter($filters); |
597 | 597 | if ($q != "") |
598 | 598 | { |
599 | - if (!is_string($q)) |
|
600 | - { |
|
599 | + if (!is_string($q)) |
|
600 | + { |
|
601 | 601 | return false; |
602 | - } else { |
|
602 | + } else { |
|
603 | 603 | |
604 | 604 | $q_array = explode(" ", $q); |
605 | 605 | |
606 | 606 | foreach ($q_array as $q_item){ |
607 | - $additional_query .= " AND ("; |
|
608 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
609 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
610 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
611 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
612 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
613 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
614 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
615 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
616 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
617 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
619 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
620 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
628 | - $translate = $Translation->ident2icao($q_item); |
|
629 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
631 | - $additional_query .= ")"; |
|
607 | + $additional_query .= " AND ("; |
|
608 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
609 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
610 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
611 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
612 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
613 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
614 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
615 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
616 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
617 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
619 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
620 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
628 | + $translate = $Translation->ident2icao($q_item); |
|
629 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
631 | + $additional_query .= ")"; |
|
632 | + } |
|
632 | 633 | } |
633 | - } |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | if ($registration != "") |
637 | 637 | { |
638 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
639 | - if (!is_string($registration)) |
|
640 | - { |
|
638 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
639 | + if (!is_string($registration)) |
|
640 | + { |
|
641 | 641 | return false; |
642 | - } else { |
|
642 | + } else { |
|
643 | 643 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
644 | - } |
|
644 | + } |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | if ($aircraft_icao != "") |
648 | 648 | { |
649 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
650 | - if (!is_string($aircraft_icao)) |
|
651 | - { |
|
649 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
650 | + if (!is_string($aircraft_icao)) |
|
651 | + { |
|
652 | 652 | return false; |
653 | - } else { |
|
653 | + } else { |
|
654 | 654 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
655 | - } |
|
655 | + } |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | if ($aircraft_manufacturer != "") |
659 | 659 | { |
660 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
661 | - if (!is_string($aircraft_manufacturer)) |
|
662 | - { |
|
660 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
661 | + if (!is_string($aircraft_manufacturer)) |
|
662 | + { |
|
663 | 663 | return false; |
664 | - } else { |
|
664 | + } else { |
|
665 | 665 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
666 | - } |
|
666 | + } |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | if ($highlights == "true") |
670 | 670 | { |
671 | - if (!is_string($highlights)) |
|
672 | - { |
|
671 | + if (!is_string($highlights)) |
|
672 | + { |
|
673 | 673 | return false; |
674 | - } else { |
|
674 | + } else { |
|
675 | 675 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
676 | - } |
|
676 | + } |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | if ($airline_icao != "") |
680 | 680 | { |
681 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
682 | - if (!is_string($airline_icao)) |
|
683 | - { |
|
681 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
682 | + if (!is_string($airline_icao)) |
|
683 | + { |
|
684 | 684 | return false; |
685 | - } else { |
|
685 | + } else { |
|
686 | 686 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
687 | - } |
|
687 | + } |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if ($airline_country != "") |
691 | 691 | { |
692 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
693 | - if (!is_string($airline_country)) |
|
694 | - { |
|
692 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
693 | + if (!is_string($airline_country)) |
|
694 | + { |
|
695 | 695 | return false; |
696 | - } else { |
|
696 | + } else { |
|
697 | 697 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
698 | - } |
|
698 | + } |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | if ($airline_type != "") |
702 | 702 | { |
703 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
704 | - if (!is_string($airline_type)) |
|
705 | - { |
|
703 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
704 | + if (!is_string($airline_type)) |
|
705 | + { |
|
706 | 706 | return false; |
707 | - } else { |
|
707 | + } else { |
|
708 | 708 | if ($airline_type == "passenger") |
709 | 709 | { |
710 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
710 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
711 | 711 | } |
712 | 712 | if ($airline_type == "cargo") |
713 | 713 | { |
714 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
714 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
715 | 715 | } |
716 | 716 | if ($airline_type == "military") |
717 | 717 | { |
718 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
718 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
719 | + } |
|
719 | 720 | } |
720 | - } |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | if ($airport != "") |
724 | 724 | { |
725 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
726 | - if (!is_string($airport)) |
|
727 | - { |
|
725 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
726 | + if (!is_string($airport)) |
|
727 | + { |
|
728 | 728 | return false; |
729 | - } else { |
|
729 | + } else { |
|
730 | 730 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | if ($airport_country != "") |
735 | 735 | { |
736 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
737 | - if (!is_string($airport_country)) |
|
738 | - { |
|
736 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
737 | + if (!is_string($airport_country)) |
|
738 | + { |
|
739 | 739 | return false; |
740 | - } else { |
|
740 | + } else { |
|
741 | 741 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
742 | - } |
|
742 | + } |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if ($callsign != "") |
746 | 746 | { |
747 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
748 | - if (!is_string($callsign)) |
|
749 | - { |
|
747 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
748 | + if (!is_string($callsign)) |
|
749 | + { |
|
750 | 750 | return false; |
751 | - } else { |
|
751 | + } else { |
|
752 | 752 | $translate = $Translation->ident2icao($callsign); |
753 | 753 | if ($translate != $callsign) { |
754 | 754 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -756,81 +756,81 @@ discard block |
||
756 | 756 | } else { |
757 | 757 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
758 | 758 | } |
759 | - } |
|
759 | + } |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | if ($owner != "") |
763 | 763 | { |
764 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
765 | - if (!is_string($owner)) |
|
766 | - { |
|
764 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
765 | + if (!is_string($owner)) |
|
766 | + { |
|
767 | 767 | return false; |
768 | - } else { |
|
768 | + } else { |
|
769 | 769 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
770 | - } |
|
770 | + } |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | if ($pilot_name != "") |
774 | 774 | { |
775 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
776 | - if (!is_string($pilot_name)) |
|
777 | - { |
|
775 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
776 | + if (!is_string($pilot_name)) |
|
777 | + { |
|
778 | 778 | return false; |
779 | - } else { |
|
779 | + } else { |
|
780 | 780 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
781 | - } |
|
781 | + } |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | if ($pilot_id != "") |
785 | 785 | { |
786 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
787 | - if (!is_string($pilot_id)) |
|
788 | - { |
|
786 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
787 | + if (!is_string($pilot_id)) |
|
788 | + { |
|
789 | 789 | return false; |
790 | - } else { |
|
790 | + } else { |
|
791 | 791 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
792 | - } |
|
792 | + } |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | if ($departure_airport_route != "") |
796 | 796 | { |
797 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
798 | - if (!is_string($departure_airport_route)) |
|
799 | - { |
|
797 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
798 | + if (!is_string($departure_airport_route)) |
|
799 | + { |
|
800 | 800 | return false; |
801 | - } else { |
|
801 | + } else { |
|
802 | 802 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
803 | - } |
|
803 | + } |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | if ($arrival_airport_route != "") |
807 | 807 | { |
808 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
809 | - if (!is_string($arrival_airport_route)) |
|
810 | - { |
|
808 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
809 | + if (!is_string($arrival_airport_route)) |
|
810 | + { |
|
811 | 811 | return false; |
812 | - } else { |
|
812 | + } else { |
|
813 | 813 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
814 | - } |
|
814 | + } |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | if ($altitude != "") |
818 | 818 | { |
819 | - $altitude_array = explode(",", $altitude); |
|
819 | + $altitude_array = explode(",", $altitude); |
|
820 | 820 | |
821 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
822 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
821 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
822 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
823 | 823 | |
824 | 824 | |
825 | - if ($altitude_array[1] != "") |
|
826 | - { |
|
825 | + if ($altitude_array[1] != "") |
|
826 | + { |
|
827 | 827 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
828 | 828 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
829 | 829 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
830 | - } else { |
|
830 | + } else { |
|
831 | 831 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
832 | 832 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
833 | - } |
|
833 | + } |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | if ($date_posted != "") |
@@ -915,14 +915,14 @@ discard block |
||
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | - /** |
|
919 | - * Gets all the spotter information based on the callsign |
|
920 | - * |
|
921 | - * @return Array the spotter information |
|
922 | - * |
|
923 | - */ |
|
924 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
925 | - { |
|
918 | + /** |
|
919 | + * Gets all the spotter information based on the callsign |
|
920 | + * |
|
921 | + * @return Array the spotter information |
|
922 | + * |
|
923 | + */ |
|
924 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
925 | + { |
|
926 | 926 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
927 | 927 | |
928 | 928 | date_default_timezone_set('UTC'); |
@@ -934,35 +934,35 @@ discard block |
||
934 | 934 | |
935 | 935 | if ($ident != "") |
936 | 936 | { |
937 | - if (!is_string($ident)) |
|
938 | - { |
|
937 | + if (!is_string($ident)) |
|
938 | + { |
|
939 | 939 | return false; |
940 | - } else { |
|
940 | + } else { |
|
941 | 941 | $additional_query = " AND spotter_archive_output.ident = :ident"; |
942 | 942 | $query_values = array(':ident' => $ident); |
943 | - } |
|
943 | + } |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | if ($limit != "") |
947 | 947 | { |
948 | - $limit_array = explode(",", $limit); |
|
948 | + $limit_array = explode(",", $limit); |
|
949 | 949 | |
950 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
951 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
950 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
951 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
952 | 952 | |
953 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
954 | - { |
|
953 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
954 | + { |
|
955 | 955 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
956 | 956 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
957 | - } |
|
957 | + } |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | if ($sort != "") |
961 | 961 | { |
962 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
963 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
962 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
963 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
964 | 964 | } else { |
965 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
965 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -970,17 +970,17 @@ discard block |
||
970 | 970 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
971 | 971 | |
972 | 972 | return $spotter_array; |
973 | - } |
|
973 | + } |
|
974 | 974 | |
975 | 975 | |
976 | - /** |
|
977 | - * Gets all the spotter information based on the owner |
|
978 | - * |
|
979 | - * @return Array the spotter information |
|
980 | - * |
|
981 | - */ |
|
982 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
983 | - { |
|
976 | + /** |
|
977 | + * Gets all the spotter information based on the owner |
|
978 | + * |
|
979 | + * @return Array the spotter information |
|
980 | + * |
|
981 | + */ |
|
982 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
983 | + { |
|
984 | 984 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
985 | 985 | |
986 | 986 | date_default_timezone_set('UTC'); |
@@ -993,35 +993,35 @@ discard block |
||
993 | 993 | |
994 | 994 | if ($owner != "") |
995 | 995 | { |
996 | - if (!is_string($owner)) |
|
997 | - { |
|
996 | + if (!is_string($owner)) |
|
997 | + { |
|
998 | 998 | return false; |
999 | - } else { |
|
999 | + } else { |
|
1000 | 1000 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1001 | 1001 | $query_values = array(':owner' => $owner); |
1002 | - } |
|
1002 | + } |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | if ($limit != "") |
1006 | 1006 | { |
1007 | - $limit_array = explode(",", $limit); |
|
1007 | + $limit_array = explode(",", $limit); |
|
1008 | 1008 | |
1009 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1010 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1009 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1010 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1011 | 1011 | |
1012 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1013 | - { |
|
1012 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1013 | + { |
|
1014 | 1014 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1015 | 1015 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1016 | - } |
|
1016 | + } |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | if ($sort != "") |
1020 | 1020 | { |
1021 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1022 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1021 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1022 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1023 | 1023 | } else { |
1024 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1024 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1029,16 +1029,16 @@ discard block |
||
1029 | 1029 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1030 | 1030 | |
1031 | 1031 | return $spotter_array; |
1032 | - } |
|
1033 | - |
|
1034 | - /** |
|
1035 | - * Gets all the spotter information based on the pilot |
|
1036 | - * |
|
1037 | - * @return Array the spotter information |
|
1038 | - * |
|
1039 | - */ |
|
1040 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1041 | - { |
|
1032 | + } |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * Gets all the spotter information based on the pilot |
|
1036 | + * |
|
1037 | + * @return Array the spotter information |
|
1038 | + * |
|
1039 | + */ |
|
1040 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1041 | + { |
|
1042 | 1042 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1043 | 1043 | |
1044 | 1044 | date_default_timezone_set('UTC'); |
@@ -1057,24 +1057,24 @@ discard block |
||
1057 | 1057 | |
1058 | 1058 | if ($limit != "") |
1059 | 1059 | { |
1060 | - $limit_array = explode(",", $limit); |
|
1060 | + $limit_array = explode(",", $limit); |
|
1061 | 1061 | |
1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1062 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1063 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1064 | 1064 | |
1065 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1066 | - { |
|
1065 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1066 | + { |
|
1067 | 1067 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1068 | 1068 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1069 | - } |
|
1069 | + } |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | if ($sort != "") |
1073 | 1073 | { |
1074 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1075 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1074 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1075 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1076 | 1076 | } else { |
1077 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1077 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1082,16 +1082,16 @@ discard block |
||
1082 | 1082 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1083 | 1083 | |
1084 | 1084 | return $spotter_array; |
1085 | - } |
|
1086 | - |
|
1087 | - /** |
|
1088 | - * Gets all number of flight over countries |
|
1089 | - * |
|
1090 | - * @return Array the airline country list |
|
1091 | - * |
|
1092 | - */ |
|
1093 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1094 | - { |
|
1085 | + } |
|
1086 | + |
|
1087 | + /** |
|
1088 | + * Gets all number of flight over countries |
|
1089 | + * |
|
1090 | + * @return Array the airline country list |
|
1091 | + * |
|
1092 | + */ |
|
1093 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1094 | + { |
|
1095 | 1095 | global $globalDBdriver; |
1096 | 1096 | /* |
1097 | 1097 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1101,14 +1101,14 @@ discard block |
||
1101 | 1101 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1102 | 1102 | FROM countries c, spotter_archive s |
1103 | 1103 | WHERE c.iso2 = s.over_country "; |
1104 | - if ($olderthanmonths > 0) { |
|
1105 | - if ($globalDBdriver == 'mysql') { |
|
1104 | + if ($olderthanmonths > 0) { |
|
1105 | + if ($globalDBdriver == 'mysql') { |
|
1106 | 1106 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1107 | 1107 | } else { |
1108 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1109 | 1109 | } |
1110 | 1110 | } |
1111 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1111 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1112 | 1112 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1113 | 1113 | if ($limit) $query .= " LIMIT 0,10"; |
1114 | 1114 | |
@@ -1121,23 +1121,23 @@ discard block |
||
1121 | 1121 | |
1122 | 1122 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1123 | 1123 | { |
1124 | - $temp_array['flight_count'] = $row['nb']; |
|
1125 | - $temp_array['flight_country'] = $row['name']; |
|
1126 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1127 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1128 | - $flight_array[] = $temp_array; |
|
1124 | + $temp_array['flight_count'] = $row['nb']; |
|
1125 | + $temp_array['flight_country'] = $row['name']; |
|
1126 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1127 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1128 | + $flight_array[] = $temp_array; |
|
1129 | 1129 | } |
1130 | 1130 | return $flight_array; |
1131 | - } |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * Gets all number of flight over countries |
|
1135 | - * |
|
1136 | - * @return Array the airline country list |
|
1137 | - * |
|
1138 | - */ |
|
1139 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1140 | - { |
|
1131 | + } |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * Gets all number of flight over countries |
|
1135 | + * |
|
1136 | + * @return Array the airline country list |
|
1137 | + * |
|
1138 | + */ |
|
1139 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1140 | + { |
|
1141 | 1141 | global $globalDBdriver; |
1142 | 1142 | /* |
1143 | 1143 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1147,14 +1147,14 @@ discard block |
||
1147 | 1147 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1148 | 1148 | FROM countries c, spotter_archive s, spotter_output o |
1149 | 1149 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1150 | - if ($olderthanmonths > 0) { |
|
1151 | - if ($globalDBdriver == 'mysql') { |
|
1150 | + if ($olderthanmonths > 0) { |
|
1151 | + if ($globalDBdriver == 'mysql') { |
|
1152 | 1152 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1153 | 1153 | } else { |
1154 | 1154 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1155 | 1155 | } |
1156 | 1156 | } |
1157 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1157 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1158 | 1158 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1159 | 1159 | if ($limit) $query .= " LIMIT 0,10"; |
1160 | 1160 | |
@@ -1167,24 +1167,24 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1169 | 1169 | { |
1170 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1171 | - $temp_array['flight_count'] = $row['nb']; |
|
1172 | - $temp_array['flight_country'] = $row['name']; |
|
1173 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1174 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1175 | - $flight_array[] = $temp_array; |
|
1170 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1171 | + $temp_array['flight_count'] = $row['nb']; |
|
1172 | + $temp_array['flight_country'] = $row['name']; |
|
1173 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1174 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1175 | + $flight_array[] = $temp_array; |
|
1176 | 1176 | } |
1177 | 1177 | return $flight_array; |
1178 | - } |
|
1179 | - |
|
1180 | - /** |
|
1181 | - * Gets last spotter information based on a particular callsign |
|
1182 | - * |
|
1183 | - * @return Array the spotter information |
|
1184 | - * |
|
1185 | - */ |
|
1186 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1187 | - { |
|
1178 | + } |
|
1179 | + |
|
1180 | + /** |
|
1181 | + * Gets last spotter information based on a particular callsign |
|
1182 | + * |
|
1183 | + * @return Array the spotter information |
|
1184 | + * |
|
1185 | + */ |
|
1186 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1187 | + { |
|
1188 | 1188 | $Spotter = new Spotter($this->db); |
1189 | 1189 | date_default_timezone_set('UTC'); |
1190 | 1190 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1192,16 +1192,16 @@ discard block |
||
1192 | 1192 | $date = date('c',$date); |
1193 | 1193 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1194 | 1194 | return $spotter_array; |
1195 | - } |
|
1196 | - |
|
1197 | - /** |
|
1198 | - * Gets all the spotter information based on a particular callsign |
|
1199 | - * |
|
1200 | - * @return Array the spotter information |
|
1201 | - * |
|
1202 | - */ |
|
1203 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1204 | - { |
|
1195 | + } |
|
1196 | + |
|
1197 | + /** |
|
1198 | + * Gets all the spotter information based on a particular callsign |
|
1199 | + * |
|
1200 | + * @return Array the spotter information |
|
1201 | + * |
|
1202 | + */ |
|
1203 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1204 | + { |
|
1205 | 1205 | $Spotter = new Spotter($this->db); |
1206 | 1206 | date_default_timezone_set('UTC'); |
1207 | 1207 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1209,16 +1209,16 @@ discard block |
||
1209 | 1209 | $date = date('c',$date); |
1210 | 1210 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1211 | 1211 | return $spotter_array; |
1212 | - } |
|
1213 | - |
|
1214 | - /** |
|
1215 | - * Gets all the spotter information based on the airport |
|
1216 | - * |
|
1217 | - * @return Array the spotter information |
|
1218 | - * |
|
1219 | - */ |
|
1220 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1221 | - { |
|
1212 | + } |
|
1213 | + |
|
1214 | + /** |
|
1215 | + * Gets all the spotter information based on the airport |
|
1216 | + * |
|
1217 | + * @return Array the spotter information |
|
1218 | + * |
|
1219 | + */ |
|
1220 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1221 | + { |
|
1222 | 1222 | global $global_query; |
1223 | 1223 | $Spotter = new Spotter($this->db); |
1224 | 1224 | date_default_timezone_set('UTC'); |
@@ -1229,35 +1229,35 @@ discard block |
||
1229 | 1229 | |
1230 | 1230 | if ($airport != "") |
1231 | 1231 | { |
1232 | - if (!is_string($airport)) |
|
1233 | - { |
|
1232 | + if (!is_string($airport)) |
|
1233 | + { |
|
1234 | 1234 | return false; |
1235 | - } else { |
|
1235 | + } else { |
|
1236 | 1236 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1237 | 1237 | $query_values = array(':airport' => $airport); |
1238 | - } |
|
1238 | + } |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | if ($limit != "") |
1242 | 1242 | { |
1243 | - $limit_array = explode(",", $limit); |
|
1243 | + $limit_array = explode(",", $limit); |
|
1244 | 1244 | |
1245 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1246 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1245 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1246 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1247 | 1247 | |
1248 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1249 | - { |
|
1248 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1249 | + { |
|
1250 | 1250 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1251 | 1251 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1252 | - } |
|
1252 | + } |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | if ($sort != "") |
1256 | 1256 | { |
1257 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1258 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1257 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1258 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1259 | 1259 | } else { |
1260 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1260 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1265,6 +1265,6 @@ discard block |
||
1265 | 1265 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1266 | 1266 | |
1267 | 1267 | return $spotter_array; |
1268 | - } |
|
1268 | + } |
|
1269 | 1269 | } |
1270 | 1270 | ?> |
1271 | 1271 | \ No newline at end of file |
@@ -329,15 +329,15 @@ |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | <?php |
332 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
332 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
333 | 333 | ?> |
334 | 334 | var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php?coord="+bbox()); |
335 | 335 | <?php |
336 | - } else { |
|
336 | + } else { |
|
337 | 337 | ?> |
338 | 338 | var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php"); |
339 | 339 | <?php |
340 | - } |
|
340 | + } |
|
341 | 341 | ?> |
342 | 342 | loc_geojson.then(function(geojsondata) { |
343 | 343 | loc = new Cesium.CustomDataSource('location'); |
@@ -85,38 +85,38 @@ discard block |
||
85 | 85 | try { |
86 | 86 | //$Connection = new Connection(); |
87 | 87 | $sth = $Connection->db->prepare($query); |
88 | - $sth->execute(array(':source' => $database_file)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - return "error : ".$e->getMessage(); |
|
91 | - } |
|
88 | + $sth->execute(array(':source' => $database_file)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + return "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | 92 | |
93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
94 | - update_db::connect_sqlite($database_file); |
|
93 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
94 | + update_db::connect_sqlite($database_file); |
|
95 | 95 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
96 | 96 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
97 | 97 | try { |
98 | - $sth = update_db::$db_sqlite->prepare($query); |
|
99 | - $sth->execute(); |
|
100 | - } catch(PDOException $e) { |
|
101 | - return "error : ".$e->getMessage(); |
|
102 | - } |
|
98 | + $sth = update_db::$db_sqlite->prepare($query); |
|
99 | + $sth->execute(); |
|
100 | + } catch(PDOException $e) { |
|
101 | + return "error : ".$e->getMessage(); |
|
102 | + } |
|
103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
104 | 104 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
105 | 105 | $Connection = new Connection(); |
106 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
107 | 107 | try { |
108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
109 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
109 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
110 | 110 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
111 | 111 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
112 | 112 | $sth_dest->execute($query_dest_values); |
113 | - } |
|
113 | + } |
|
114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
115 | 115 | } catch(PDOException $e) { |
116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
117 | 117 | return "error : ".$e->getMessage(); |
118 | 118 | } |
119 | - return ''; |
|
119 | + return ''; |
|
120 | 120 | } |
121 | 121 | public static function retrieve_route_oneworld($database_file) { |
122 | 122 | global $globalDebug, $globalTransaction; |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | try { |
128 | 128 | //$Connection = new Connection(); |
129 | 129 | $sth = $Connection->db->prepare($query); |
130 | - $sth->execute(array(':source' => 'oneworld')); |
|
131 | - } catch(PDOException $e) { |
|
132 | - return "error : ".$e->getMessage(); |
|
133 | - } |
|
130 | + $sth->execute(array(':source' => 'oneworld')); |
|
131 | + } catch(PDOException $e) { |
|
132 | + return "error : ".$e->getMessage(); |
|
133 | + } |
|
134 | 134 | |
135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
135 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
137 | 137 | $Spotter = new Spotter(); |
138 | 138 | if ($fh = fopen($database_file,"r")) { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | if ($globalTransaction) $Connection->db->commit(); |
158 | 158 | } |
159 | - return ''; |
|
159 | + return ''; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | public static function retrieve_route_skyteam($database_file) { |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | try { |
169 | 169 | //$Connection = new Connection(); |
170 | 170 | $sth = $Connection->db->prepare($query); |
171 | - $sth->execute(array(':source' => 'skyteam')); |
|
172 | - } catch(PDOException $e) { |
|
173 | - return "error : ".$e->getMessage(); |
|
174 | - } |
|
171 | + $sth->execute(array(':source' => 'skyteam')); |
|
172 | + } catch(PDOException $e) { |
|
173 | + return "error : ".$e->getMessage(); |
|
174 | + } |
|
175 | 175 | |
176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
176 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
177 | 177 | |
178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
179 | 179 | $Spotter = new Spotter(); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | return "error : ".$e->getMessage(); |
200 | 200 | } |
201 | 201 | } |
202 | - return ''; |
|
202 | + return ''; |
|
203 | 203 | } |
204 | 204 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
205 | 205 | global $globalTransaction; |
@@ -208,27 +208,27 @@ discard block |
||
208 | 208 | try { |
209 | 209 | $Connection = new Connection(); |
210 | 210 | $sth = $Connection->db->prepare($query); |
211 | - $sth->execute(array(':source' => $database_file)); |
|
212 | - } catch(PDOException $e) { |
|
213 | - return "error : ".$e->getMessage(); |
|
214 | - } |
|
211 | + $sth->execute(array(':source' => $database_file)); |
|
212 | + } catch(PDOException $e) { |
|
213 | + return "error : ".$e->getMessage(); |
|
214 | + } |
|
215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
216 | 216 | try { |
217 | 217 | $Connection = new Connection(); |
218 | 218 | $sth = $Connection->db->prepare($query); |
219 | - $sth->execute(array(':source' => $database_file)); |
|
220 | - } catch(PDOException $e) { |
|
221 | - return "error : ".$e->getMessage(); |
|
222 | - } |
|
219 | + $sth->execute(array(':source' => $database_file)); |
|
220 | + } catch(PDOException $e) { |
|
221 | + return "error : ".$e->getMessage(); |
|
222 | + } |
|
223 | 223 | |
224 | - update_db::connect_sqlite($database_file); |
|
224 | + update_db::connect_sqlite($database_file); |
|
225 | 225 | $query = 'select * from Aircraft'; |
226 | 226 | try { |
227 | - $sth = update_db::$db_sqlite->prepare($query); |
|
228 | - $sth->execute(); |
|
229 | - } catch(PDOException $e) { |
|
230 | - return "error : ".$e->getMessage(); |
|
231 | - } |
|
227 | + $sth = update_db::$db_sqlite->prepare($query); |
|
228 | + $sth->execute(); |
|
229 | + } catch(PDOException $e) { |
|
230 | + return "error : ".$e->getMessage(); |
|
231 | + } |
|
232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
233 | 233 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
234 | 234 | |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
240 | 240 | try { |
241 | 241 | if ($globalTransaction) $Connection->db->beginTransaction(); |
242 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
242 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
243 | 243 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
244 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
245 | 245 | else $type = null; |
246 | 246 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
247 | 247 | $sth_dest->execute($query_dest_values); |
248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
250 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
249 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
250 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
251 | 251 | } |
252 | - } |
|
252 | + } |
|
253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
254 | 254 | } catch(PDOException $e) { |
255 | 255 | return "error : ".$e->getMessage(); |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | try { |
261 | 261 | $Connection = new Connection(); |
262 | 262 | $sth = $Connection->db->prepare($query); |
263 | - $sth->execute(array(':source' => $database_file)); |
|
264 | - } catch(PDOException $e) { |
|
265 | - return "error : ".$e->getMessage(); |
|
266 | - } |
|
263 | + $sth->execute(array(':source' => $database_file)); |
|
264 | + } catch(PDOException $e) { |
|
265 | + return "error : ".$e->getMessage(); |
|
266 | + } |
|
267 | 267 | return ''; |
268 | 268 | } |
269 | 269 | |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | try { |
276 | 276 | $Connection = new Connection(); |
277 | 277 | $sth = $Connection->db->prepare($query); |
278 | - $sth->execute(array(':source' => $database_file)); |
|
279 | - } catch(PDOException $e) { |
|
280 | - return "error : ".$e->getMessage(); |
|
281 | - } |
|
278 | + $sth->execute(array(':source' => $database_file)); |
|
279 | + } catch(PDOException $e) { |
|
280 | + return "error : ".$e->getMessage(); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | if ($fh = fopen($database_file,"r")) { |
284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -288,26 +288,26 @@ discard block |
||
288 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
289 | 289 | try { |
290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
291 | - while (!feof($fh)) { |
|
292 | - $values = array(); |
|
293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
291 | + while (!feof($fh)) { |
|
292 | + $values = array(); |
|
293 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
295 | - $values['ModeS'] = substr($line,0,6); |
|
296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
297 | - $aircraft_name = trim(substr($line,48,6)); |
|
298 | - // Check if we can find ICAO, else set it to GLID |
|
299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
300 | - $search_more = ''; |
|
301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
302 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
303 | - $sth_search = $Connection->db->prepare($query_search); |
|
295 | + $values['ModeS'] = substr($line,0,6); |
|
296 | + $values['Registration'] = trim(substr($line,69,6)); |
|
297 | + $aircraft_name = trim(substr($line,48,6)); |
|
298 | + // Check if we can find ICAO, else set it to GLID |
|
299 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
300 | + $search_more = ''; |
|
301 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
302 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
303 | + $sth_search = $Connection->db->prepare($query_search); |
|
304 | 304 | try { |
305 | - $sth_search->execute(); |
|
306 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
307 | - //if (count($result) > 0) { |
|
308 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
309 | - $values['ICAOTypeCode'] = $result['icao']; |
|
310 | - } |
|
305 | + $sth_search->execute(); |
|
306 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
307 | + //if (count($result) > 0) { |
|
308 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
309 | + $values['ICAOTypeCode'] = $result['icao']; |
|
310 | + } |
|
311 | 311 | } catch(PDOException $e) { |
312 | 312 | return "error : ".$e->getMessage(); |
313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | try { |
331 | 331 | $Connection = new Connection(); |
332 | 332 | $sth = $Connection->db->prepare($query); |
333 | - $sth->execute(array(':source' => $database_file)); |
|
334 | - } catch(PDOException $e) { |
|
335 | - return "error : ".$e->getMessage(); |
|
336 | - } |
|
333 | + $sth->execute(array(':source' => $database_file)); |
|
334 | + } catch(PDOException $e) { |
|
335 | + return "error : ".$e->getMessage(); |
|
336 | + } |
|
337 | 337 | return ''; |
338 | 338 | } |
339 | 339 | |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | try { |
345 | 345 | $Connection = new Connection(); |
346 | 346 | $sth = $Connection->db->prepare($query); |
347 | - $sth->execute(array(':source' => $database_file)); |
|
348 | - } catch(PDOException $e) { |
|
349 | - return "error : ".$e->getMessage(); |
|
350 | - } |
|
347 | + $sth->execute(array(':source' => $database_file)); |
|
348 | + } catch(PDOException $e) { |
|
349 | + return "error : ".$e->getMessage(); |
|
350 | + } |
|
351 | 351 | |
352 | 352 | if ($fh = fopen($database_file,"r")) { |
353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -358,25 +358,25 @@ discard block |
||
358 | 358 | try { |
359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
360 | 360 | $tmp = fgetcsv($fh,9999,',',"'"); |
361 | - while (!feof($fh)) { |
|
362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
361 | + while (!feof($fh)) { |
|
362 | + $line = fgetcsv($fh,9999,',',"'"); |
|
363 | 363 | |
364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
365 | 365 | //print_r($line); |
366 | - $values['ModeS'] = $line[1]; |
|
367 | - $values['Registration'] = $line[3]; |
|
368 | - $values['ICAOTypeCode'] = ''; |
|
369 | - $aircraft_name = $line[2]; |
|
370 | - // Check if we can find ICAO, else set it to GLID |
|
371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
372 | - $search_more = ''; |
|
373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
374 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
375 | - $sth_search = $Connection->db->prepare($query_search); |
|
366 | + $values['ModeS'] = $line[1]; |
|
367 | + $values['Registration'] = $line[3]; |
|
368 | + $values['ICAOTypeCode'] = ''; |
|
369 | + $aircraft_name = $line[2]; |
|
370 | + // Check if we can find ICAO, else set it to GLID |
|
371 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
372 | + $search_more = ''; |
|
373 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
374 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
375 | + $sth_search = $Connection->db->prepare($query_search); |
|
376 | 376 | try { |
377 | - $sth_search->execute(); |
|
378 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
377 | + $sth_search->execute(); |
|
378 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
379 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
380 | 380 | } catch(PDOException $e) { |
381 | 381 | return "error : ".$e->getMessage(); |
382 | 382 | } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | try { |
400 | 400 | $Connection = new Connection(); |
401 | 401 | $sth = $Connection->db->prepare($query); |
402 | - $sth->execute(array(':source' => $database_file)); |
|
403 | - } catch(PDOException $e) { |
|
404 | - return "error : ".$e->getMessage(); |
|
405 | - } |
|
402 | + $sth->execute(array(':source' => $database_file)); |
|
403 | + } catch(PDOException $e) { |
|
404 | + return "error : ".$e->getMessage(); |
|
405 | + } |
|
406 | 406 | return ''; |
407 | 407 | } |
408 | 408 | |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | try { |
414 | 414 | $Connection = new Connection(); |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | - $sth->execute(array(':source' => $database_file)); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error : ".$e->getMessage(); |
|
419 | - } |
|
416 | + $sth->execute(array(':source' => $database_file)); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error : ".$e->getMessage(); |
|
419 | + } |
|
420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
421 | 421 | $Spotter = new Spotter(); |
422 | 422 | if ($fh = fopen($database_file,"r")) { |
423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
425 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
425 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
426 | 426 | |
427 | 427 | $Connection = new Connection(); |
428 | 428 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -430,126 +430,126 @@ discard block |
||
430 | 430 | try { |
431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
432 | 432 | $tmp = fgetcsv($fh,9999,',','"'); |
433 | - while (!feof($fh)) { |
|
434 | - $line = fgetcsv($fh,9999,',','"'); |
|
435 | - $values = array(); |
|
436 | - //print_r($line); |
|
437 | - if ($country == 'F') { |
|
438 | - $values['registration'] = $line[0]; |
|
439 | - $values['base'] = $line[4]; |
|
440 | - $values['owner'] = $line[5]; |
|
441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
443 | - $values['cancel'] = $line[7]; |
|
433 | + while (!feof($fh)) { |
|
434 | + $line = fgetcsv($fh,9999,',','"'); |
|
435 | + $values = array(); |
|
436 | + //print_r($line); |
|
437 | + if ($country == 'F') { |
|
438 | + $values['registration'] = $line[0]; |
|
439 | + $values['base'] = $line[4]; |
|
440 | + $values['owner'] = $line[5]; |
|
441 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
443 | + $values['cancel'] = $line[7]; |
|
444 | 444 | } elseif ($country == 'EI') { |
445 | - // TODO : add modeS & reg to aircraft_modes |
|
446 | - $values['registration'] = $line[0]; |
|
447 | - $values['base'] = $line[3]; |
|
448 | - $values['owner'] = $line[2]; |
|
449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
451 | - $values['cancel'] = ''; |
|
452 | - $values['modes'] = $line[7]; |
|
453 | - $values['icao'] = $line[8]; |
|
445 | + // TODO : add modeS & reg to aircraft_modes |
|
446 | + $values['registration'] = $line[0]; |
|
447 | + $values['base'] = $line[3]; |
|
448 | + $values['owner'] = $line[2]; |
|
449 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
451 | + $values['cancel'] = ''; |
|
452 | + $values['modes'] = $line[7]; |
|
453 | + $values['icao'] = $line[8]; |
|
454 | 454 | |
455 | 455 | } elseif ($country == 'HB') { |
456 | - // TODO : add modeS & reg to aircraft_modes |
|
457 | - $values['registration'] = $line[0]; |
|
458 | - $values['base'] = null; |
|
459 | - $values['owner'] = $line[5]; |
|
460 | - $values['date_first_reg'] = null; |
|
461 | - $values['cancel'] = ''; |
|
462 | - $values['modes'] = $line[4]; |
|
463 | - $values['icao'] = $line[7]; |
|
456 | + // TODO : add modeS & reg to aircraft_modes |
|
457 | + $values['registration'] = $line[0]; |
|
458 | + $values['base'] = null; |
|
459 | + $values['owner'] = $line[5]; |
|
460 | + $values['date_first_reg'] = null; |
|
461 | + $values['cancel'] = ''; |
|
462 | + $values['modes'] = $line[4]; |
|
463 | + $values['icao'] = $line[7]; |
|
464 | 464 | } elseif ($country == 'OK') { |
465 | - // TODO : add modeS & reg to aircraft_modes |
|
466 | - $values['registration'] = $line[3]; |
|
467 | - $values['base'] = null; |
|
468 | - $values['owner'] = $line[5]; |
|
469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
471 | - $values['cancel'] = ''; |
|
465 | + // TODO : add modeS & reg to aircraft_modes |
|
466 | + $values['registration'] = $line[3]; |
|
467 | + $values['base'] = null; |
|
468 | + $values['owner'] = $line[5]; |
|
469 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
471 | + $values['cancel'] = ''; |
|
472 | 472 | } elseif ($country == 'VH') { |
473 | - // TODO : add modeS & reg to aircraft_modes |
|
474 | - $values['registration'] = $line[0]; |
|
475 | - $values['base'] = null; |
|
476 | - $values['owner'] = $line[12]; |
|
477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
479 | - |
|
480 | - $values['cancel'] = $line[39]; |
|
473 | + // TODO : add modeS & reg to aircraft_modes |
|
474 | + $values['registration'] = $line[0]; |
|
475 | + $values['base'] = null; |
|
476 | + $values['owner'] = $line[12]; |
|
477 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
479 | + |
|
480 | + $values['cancel'] = $line[39]; |
|
481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
482 | - $values['registration'] = $line[0]; |
|
483 | - $values['base'] = null; |
|
484 | - $values['owner'] = $line[4]; |
|
485 | - $values['date_first_reg'] = null; |
|
486 | - $values['cancel'] = ''; |
|
482 | + $values['registration'] = $line[0]; |
|
483 | + $values['base'] = null; |
|
484 | + $values['owner'] = $line[4]; |
|
485 | + $values['date_first_reg'] = null; |
|
486 | + $values['cancel'] = ''; |
|
487 | 487 | } elseif ($country == 'CC') { |
488 | - $values['registration'] = $line[0]; |
|
489 | - $values['base'] = null; |
|
490 | - $values['owner'] = $line[6]; |
|
491 | - $values['date_first_reg'] = null; |
|
492 | - $values['cancel'] = ''; |
|
488 | + $values['registration'] = $line[0]; |
|
489 | + $values['base'] = null; |
|
490 | + $values['owner'] = $line[6]; |
|
491 | + $values['date_first_reg'] = null; |
|
492 | + $values['cancel'] = ''; |
|
493 | 493 | } elseif ($country == 'HJ') { |
494 | - $values['registration'] = $line[0]; |
|
495 | - $values['base'] = null; |
|
496 | - $values['owner'] = $line[8]; |
|
497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | - $values['cancel'] = ''; |
|
494 | + $values['registration'] = $line[0]; |
|
495 | + $values['base'] = null; |
|
496 | + $values['owner'] = $line[8]; |
|
497 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | + $values['cancel'] = ''; |
|
500 | 500 | } elseif ($country == 'PP') { |
501 | - $values['registration'] = $line[0]; |
|
502 | - $values['base'] = null; |
|
503 | - $values['owner'] = $line[4]; |
|
504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | - $values['cancel'] = $line[7]; |
|
501 | + $values['registration'] = $line[0]; |
|
502 | + $values['base'] = null; |
|
503 | + $values['owner'] = $line[4]; |
|
504 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | + $values['cancel'] = $line[7]; |
|
507 | 507 | } elseif ($country == 'E7') { |
508 | - $values['registration'] = $line[0]; |
|
509 | - $values['base'] = null; |
|
510 | - $values['owner'] = $line[4]; |
|
511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
513 | - $values['cancel'] = ''; |
|
508 | + $values['registration'] = $line[0]; |
|
509 | + $values['base'] = null; |
|
510 | + $values['owner'] = $line[4]; |
|
511 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
513 | + $values['cancel'] = ''; |
|
514 | 514 | } elseif ($country == '8Q') { |
515 | - $values['registration'] = $line[0]; |
|
516 | - $values['base'] = null; |
|
517 | - $values['owner'] = $line[3]; |
|
518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
520 | - $values['cancel'] = ''; |
|
515 | + $values['registration'] = $line[0]; |
|
516 | + $values['base'] = null; |
|
517 | + $values['owner'] = $line[3]; |
|
518 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
520 | + $values['cancel'] = ''; |
|
521 | 521 | } elseif ($country == 'ZK') { |
522 | - $values['registration'] = $line[0]; |
|
523 | - $values['base'] = null; |
|
524 | - $values['owner'] = $line[3]; |
|
525 | - $values['date_first_reg'] = null; |
|
526 | - $values['cancel'] = ''; |
|
527 | - $values['modes'] = $line[5]; |
|
528 | - $values['icao'] = $line[9]; |
|
522 | + $values['registration'] = $line[0]; |
|
523 | + $values['base'] = null; |
|
524 | + $values['owner'] = $line[3]; |
|
525 | + $values['date_first_reg'] = null; |
|
526 | + $values['cancel'] = ''; |
|
527 | + $values['modes'] = $line[5]; |
|
528 | + $values['icao'] = $line[9]; |
|
529 | 529 | } elseif ($country == 'M') { |
530 | - $values['registration'] = $line[0]; |
|
531 | - $values['base'] = null; |
|
532 | - $values['owner'] = $line[6]; |
|
533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
535 | - $values['modes'] = $line[4]; |
|
536 | - $values['icao'] = $line[10]; |
|
530 | + $values['registration'] = $line[0]; |
|
531 | + $values['base'] = null; |
|
532 | + $values['owner'] = $line[6]; |
|
533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
534 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
535 | + $values['modes'] = $line[4]; |
|
536 | + $values['icao'] = $line[10]; |
|
537 | 537 | } elseif ($country == 'OY') { |
538 | - $values['registration'] = $line[0]; |
|
539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
540 | - $values['modes'] = $line[5]; |
|
541 | - $values['icao'] = $line[6]; |
|
538 | + $values['registration'] = $line[0]; |
|
539 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
540 | + $values['modes'] = $line[5]; |
|
541 | + $values['icao'] = $line[6]; |
|
542 | 542 | } elseif ($country == 'PH') { |
543 | - $values['registration'] = $line[0]; |
|
544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
545 | - $values['modes'] = $line[4]; |
|
546 | - $values['icao'] = $line[5]; |
|
543 | + $values['registration'] = $line[0]; |
|
544 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
545 | + $values['modes'] = $line[4]; |
|
546 | + $values['icao'] = $line[5]; |
|
547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
548 | - $values['registration'] = $line[0]; |
|
549 | - $values['base'] = null; |
|
550 | - $values['owner'] = $line[3]; |
|
551 | - $values['date_first_reg'] = null; |
|
552 | - $values['cancel'] = ''; |
|
548 | + $values['registration'] = $line[0]; |
|
549 | + $values['base'] = null; |
|
550 | + $values['owner'] = $line[3]; |
|
551 | + $values['date_first_reg'] = null; |
|
552 | + $values['cancel'] = ''; |
|
553 | 553 | } |
554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
555 | 555 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | return "error : ".$e->getMessage(); |
683 | 683 | } |
684 | 684 | */ |
685 | - /* |
|
685 | + /* |
|
686 | 686 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
687 | 687 | try { |
688 | 688 | $Connection = new Connection(); |
@@ -927,10 +927,10 @@ discard block |
||
927 | 927 | try { |
928 | 928 | $Connection = new Connection(); |
929 | 929 | $sth = $Connection->db->prepare($query); |
930 | - $sth->execute(array(':source' => 'translation.csv')); |
|
931 | - } catch(PDOException $e) { |
|
932 | - return "error : ".$e->getMessage(); |
|
933 | - } |
|
930 | + $sth->execute(array(':source' => 'translation.csv')); |
|
931 | + } catch(PDOException $e) { |
|
932 | + return "error : ".$e->getMessage(); |
|
933 | + } |
|
934 | 934 | |
935 | 935 | |
936 | 936 | //update_db::unzip($out_file); |
@@ -949,21 +949,21 @@ discard block |
||
949 | 949 | $data = $row; |
950 | 950 | $operator = $data[2]; |
951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
952 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
953 | - //echo substr($operator, 0, 2)."\n";; |
|
954 | - if (count($airline_array) > 0) { |
|
952 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
953 | + //echo substr($operator, 0, 2)."\n";; |
|
954 | + if (count($airline_array) > 0) { |
|
955 | 955 | //print_r($airline_array); |
956 | 956 | $operator = $airline_array[0]['icao'].substr($operator,2); |
957 | - } |
|
958 | - } |
|
957 | + } |
|
958 | + } |
|
959 | 959 | |
960 | 960 | $operator_correct = $data[3]; |
961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
962 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
963 | - if (count($airline_array) > 0) { |
|
964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
965 | - } |
|
966 | - } |
|
962 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
963 | + if (count($airline_array) > 0) { |
|
964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
965 | + } |
|
966 | + } |
|
967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
968 | 968 | try { |
969 | 969 | $sth = $Connection->db->prepare($query); |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | //$Connection->db->commit(); |
978 | 978 | } |
979 | 979 | return ''; |
980 | - } |
|
980 | + } |
|
981 | 981 | |
982 | 982 | public static function translation_fam() { |
983 | 983 | global $tmp_dir, $globalTransaction; |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | //$Connection->db->commit(); |
1016 | 1016 | } |
1017 | 1017 | return ''; |
1018 | - } |
|
1018 | + } |
|
1019 | 1019 | |
1020 | 1020 | /* |
1021 | 1021 | * This function use FAA public data. |
@@ -1027,19 +1027,19 @@ discard block |
||
1027 | 1027 | try { |
1028 | 1028 | $Connection = new Connection(); |
1029 | 1029 | $sth = $Connection->db->prepare($query); |
1030 | - $sth->execute(array(':source' => 'website_faa')); |
|
1031 | - } catch(PDOException $e) { |
|
1032 | - return "error : ".$e->getMessage(); |
|
1033 | - } |
|
1030 | + $sth->execute(array(':source' => 'website_faa')); |
|
1031 | + } catch(PDOException $e) { |
|
1032 | + return "error : ".$e->getMessage(); |
|
1033 | + } |
|
1034 | 1034 | |
1035 | 1035 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1036 | 1036 | try { |
1037 | 1037 | $Connection = new Connection(); |
1038 | 1038 | $sth = $Connection->db->prepare($query); |
1039 | - $sth->execute(array(':source' => 'website_faa')); |
|
1040 | - } catch(PDOException $e) { |
|
1041 | - return "error : ".$e->getMessage(); |
|
1042 | - } |
|
1039 | + $sth->execute(array(':source' => 'website_faa')); |
|
1040 | + } catch(PDOException $e) { |
|
1041 | + return "error : ".$e->getMessage(); |
|
1042 | + } |
|
1043 | 1043 | |
1044 | 1044 | $delimiter = ","; |
1045 | 1045 | $mfr = array(); |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | */ |
1209 | 1209 | return ''; |
1210 | - } |
|
1210 | + } |
|
1211 | 1211 | |
1212 | 1212 | public static function owner_fam() { |
1213 | 1213 | global $tmp_dir, $globalTransaction; |
@@ -1215,10 +1215,10 @@ discard block |
||
1215 | 1215 | try { |
1216 | 1216 | $Connection = new Connection(); |
1217 | 1217 | $sth = $Connection->db->prepare($query); |
1218 | - $sth->execute(array(':source' => 'website_fam')); |
|
1219 | - } catch(PDOException $e) { |
|
1220 | - return "error : ".$e->getMessage(); |
|
1221 | - } |
|
1218 | + $sth->execute(array(':source' => 'website_fam')); |
|
1219 | + } catch(PDOException $e) { |
|
1220 | + return "error : ".$e->getMessage(); |
|
1221 | + } |
|
1222 | 1222 | |
1223 | 1223 | $delimiter = "\t"; |
1224 | 1224 | $Connection = new Connection(); |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | if ($globalTransaction) $Connection->db->commit(); |
1245 | 1245 | } |
1246 | 1246 | return ''; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | |
1249 | 1249 | public static function routes_fam() { |
1250 | 1250 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | if ($globalTransaction) $Connection->db->commit(); |
1280 | 1280 | } |
1281 | 1281 | return ''; |
1282 | - } |
|
1282 | + } |
|
1283 | 1283 | |
1284 | 1284 | public static function marine_identity_fam() { |
1285 | 1285 | global $tmp_dir, $globalTransaction; |
@@ -1287,10 +1287,10 @@ discard block |
||
1287 | 1287 | try { |
1288 | 1288 | $Connection = new Connection(); |
1289 | 1289 | $sth = $Connection->db->prepare($query); |
1290 | - $sth->execute(); |
|
1291 | - } catch(PDOException $e) { |
|
1292 | - return "error : ".$e->getMessage(); |
|
1293 | - } |
|
1290 | + $sth->execute(); |
|
1291 | + } catch(PDOException $e) { |
|
1292 | + return "error : ".$e->getMessage(); |
|
1293 | + } |
|
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | //update_db::unzip($out_file); |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | if ($globalTransaction) $Connection->db->commit(); |
1321 | 1321 | } |
1322 | 1322 | return ''; |
1323 | - } |
|
1323 | + } |
|
1324 | 1324 | |
1325 | 1325 | public static function satellite_fam() { |
1326 | 1326 | global $tmp_dir, $globalTransaction; |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | if ($globalTransaction) $Connection->db->commit(); |
1392 | 1392 | } |
1393 | 1393 | return ''; |
1394 | - } |
|
1394 | + } |
|
1395 | 1395 | |
1396 | 1396 | public static function tle($filename,$tletype) { |
1397 | 1397 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1402,10 +1402,10 @@ discard block |
||
1402 | 1402 | try { |
1403 | 1403 | $Connection = new Connection(); |
1404 | 1404 | $sth = $Connection->db->prepare($query); |
1405 | - $sth->execute(array(':source' => $filename)); |
|
1406 | - } catch(PDOException $e) { |
|
1407 | - return "error : ".$e->getMessage(); |
|
1408 | - } |
|
1405 | + $sth->execute(array(':source' => $filename)); |
|
1406 | + } catch(PDOException $e) { |
|
1407 | + return "error : ".$e->getMessage(); |
|
1408 | + } |
|
1409 | 1409 | |
1410 | 1410 | $Connection = new Connection(); |
1411 | 1411 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | //$Connection->db->commit(); |
1441 | 1441 | } |
1442 | 1442 | return ''; |
1443 | - } |
|
1443 | + } |
|
1444 | 1444 | |
1445 | 1445 | public static function satellite_ucsdb($filename) { |
1446 | 1446 | global $tmp_dir, $globalTransaction; |
@@ -1699,11 +1699,11 @@ discard block |
||
1699 | 1699 | try { |
1700 | 1700 | $sth = $Connection->db->prepare($query); |
1701 | 1701 | $sth->execute(array( |
1702 | - ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
1703 | - ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
1704 | - ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
1705 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1706 | - ) |
|
1702 | + ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
1703 | + ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
1704 | + ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
1705 | + ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1706 | + ) |
|
1707 | 1707 | ); |
1708 | 1708 | } catch(PDOException $e) { |
1709 | 1709 | return "error : ".$e->getMessage(); |
@@ -1727,13 +1727,13 @@ discard block |
||
1727 | 1727 | //$Connection->db->commit(); |
1728 | 1728 | } |
1729 | 1729 | return ''; |
1730 | - } |
|
1730 | + } |
|
1731 | 1731 | |
1732 | 1732 | /** |
1733 | - * Convert a HTML table to an array |
|
1734 | - * @param String $data HTML page |
|
1735 | - * @return Array array of the tables in HTML page |
|
1736 | - */ |
|
1733 | + * Convert a HTML table to an array |
|
1734 | + * @param String $data HTML page |
|
1735 | + * @return Array array of the tables in HTML page |
|
1736 | + */ |
|
1737 | 1737 | /* |
1738 | 1738 | private static function table2array($data) { |
1739 | 1739 | $html = str_get_html($data); |
@@ -1763,11 +1763,11 @@ discard block |
||
1763 | 1763 | return(array_filter($tabledata)); |
1764 | 1764 | } |
1765 | 1765 | */ |
1766 | - /** |
|
1767 | - * Get data from form result |
|
1768 | - * @param String $url form URL |
|
1769 | - * @return String the result |
|
1770 | - */ |
|
1766 | + /** |
|
1767 | + * Get data from form result |
|
1768 | + * @param String $url form URL |
|
1769 | + * @return String the result |
|
1770 | + */ |
|
1771 | 1771 | /* |
1772 | 1772 | private static function getData($url) { |
1773 | 1773 | $ch = curl_init(); |
@@ -1917,7 +1917,7 @@ discard block |
||
1917 | 1917 | if ($globalTransaction) $Connection->db->commit(); |
1918 | 1918 | } |
1919 | 1919 | return ''; |
1920 | - } |
|
1920 | + } |
|
1921 | 1921 | |
1922 | 1922 | public static function update_airspace() { |
1923 | 1923 | global $tmp_dir, $globalDBdriver; |
@@ -1927,11 +1927,11 @@ discard block |
||
1927 | 1927 | $query = 'DROP TABLE airspace'; |
1928 | 1928 | try { |
1929 | 1929 | $sth = $Connection->db->prepare($query); |
1930 | - $sth->execute(); |
|
1931 | - } catch(PDOException $e) { |
|
1930 | + $sth->execute(); |
|
1931 | + } catch(PDOException $e) { |
|
1932 | 1932 | return "error : ".$e->getMessage(); |
1933 | - } |
|
1934 | - } |
|
1933 | + } |
|
1934 | + } |
|
1935 | 1935 | |
1936 | 1936 | |
1937 | 1937 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1996,10 +1996,10 @@ discard block |
||
1996 | 1996 | $query = 'DROP TABLE countries'; |
1997 | 1997 | try { |
1998 | 1998 | $sth = $Connection->db->prepare($query); |
1999 | - $sth->execute(); |
|
2000 | - } catch(PDOException $e) { |
|
2001 | - echo "error : ".$e->getMessage(); |
|
2002 | - } |
|
1999 | + $sth->execute(); |
|
2000 | + } catch(PDOException $e) { |
|
2001 | + echo "error : ".$e->getMessage(); |
|
2002 | + } |
|
2003 | 2003 | } |
2004 | 2004 | if ($globalDBdriver == 'mysql') { |
2005 | 2005 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2458,7 +2458,7 @@ discard block |
||
2458 | 2458 | $error = update_db::airlines_fam(); |
2459 | 2459 | update_db::insert_airlines_version($airlines_md5); |
2460 | 2460 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
2461 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2461 | + } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2462 | 2462 | } elseif ($globalDebug) echo "No update."; |
2463 | 2463 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
2464 | 2464 | if ($error != '') { |
@@ -2832,12 +2832,12 @@ discard block |
||
2832 | 2832 | echo $data; |
2833 | 2833 | */ |
2834 | 2834 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2835 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2836 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2837 | - $result = fread($fh,100000000); |
|
2838 | - //echo $result; |
|
2839 | - //var_dump(str_get_html($result)); |
|
2840 | - //print_r(self::table2array($result)); |
|
2835 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2836 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2837 | + $result = fread($fh,100000000); |
|
2838 | + //echo $result; |
|
2839 | + //var_dump(str_get_html($result)); |
|
2840 | + //print_r(self::table2array($result)); |
|
2841 | 2841 | } |
2842 | 2842 | |
2843 | 2843 | } |
@@ -2851,10 +2851,10 @@ discard block |
||
2851 | 2851 | try { |
2852 | 2852 | $Connection = new Connection(); |
2853 | 2853 | $sth = $Connection->db->prepare($query); |
2854 | - $sth->execute(); |
|
2855 | - } catch(PDOException $e) { |
|
2856 | - return "error : ".$e->getMessage(); |
|
2857 | - } |
|
2854 | + $sth->execute(); |
|
2855 | + } catch(PDOException $e) { |
|
2856 | + return "error : ".$e->getMessage(); |
|
2857 | + } |
|
2858 | 2858 | |
2859 | 2859 | $error = ''; |
2860 | 2860 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2910,8 +2910,8 @@ discard block |
||
2910 | 2910 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2911 | 2911 | $data['permanent'] = 0; |
2912 | 2912 | } else { |
2913 | - $data['date_end'] = NULL; |
|
2914 | - $data['permanent'] = 1; |
|
2913 | + $data['date_end'] = NULL; |
|
2914 | + $data['permanent'] = 1; |
|
2915 | 2915 | } |
2916 | 2916 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2917 | 2917 | $NOTAM = new NOTAM(); |
@@ -2985,13 +2985,13 @@ discard block |
||
2985 | 2985 | try { |
2986 | 2986 | $Connection = new Connection(); |
2987 | 2987 | $sth = $Connection->db->prepare($query); |
2988 | - $sth->execute(); |
|
2989 | - } catch(PDOException $e) { |
|
2990 | - return "error : ".$e->getMessage(); |
|
2991 | - } |
|
2992 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2993 | - if ($row['nb'] > 0) return false; |
|
2994 | - else return true; |
|
2988 | + $sth->execute(); |
|
2989 | + } catch(PDOException $e) { |
|
2990 | + return "error : ".$e->getMessage(); |
|
2991 | + } |
|
2992 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2993 | + if ($row['nb'] > 0) return false; |
|
2994 | + else return true; |
|
2995 | 2995 | } |
2996 | 2996 | |
2997 | 2997 | public static function insert_last_update() { |
@@ -3000,10 +3000,10 @@ discard block |
||
3000 | 3000 | try { |
3001 | 3001 | $Connection = new Connection(); |
3002 | 3002 | $sth = $Connection->db->prepare($query); |
3003 | - $sth->execute(); |
|
3004 | - } catch(PDOException $e) { |
|
3005 | - return "error : ".$e->getMessage(); |
|
3006 | - } |
|
3003 | + $sth->execute(); |
|
3004 | + } catch(PDOException $e) { |
|
3005 | + return "error : ".$e->getMessage(); |
|
3006 | + } |
|
3007 | 3007 | } |
3008 | 3008 | |
3009 | 3009 | public static function check_airspace_version($version) { |
@@ -3011,13 +3011,13 @@ discard block |
||
3011 | 3011 | try { |
3012 | 3012 | $Connection = new Connection(); |
3013 | 3013 | $sth = $Connection->db->prepare($query); |
3014 | - $sth->execute(array(':version' => $version)); |
|
3015 | - } catch(PDOException $e) { |
|
3016 | - return "error : ".$e->getMessage(); |
|
3017 | - } |
|
3018 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3019 | - if ($row['nb'] > 0) return true; |
|
3020 | - else return false; |
|
3014 | + $sth->execute(array(':version' => $version)); |
|
3015 | + } catch(PDOException $e) { |
|
3016 | + return "error : ".$e->getMessage(); |
|
3017 | + } |
|
3018 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3019 | + if ($row['nb'] > 0) return true; |
|
3020 | + else return false; |
|
3021 | 3021 | } |
3022 | 3022 | |
3023 | 3023 | public static function check_geoid_version($version) { |
@@ -3025,13 +3025,13 @@ discard block |
||
3025 | 3025 | try { |
3026 | 3026 | $Connection = new Connection(); |
3027 | 3027 | $sth = $Connection->db->prepare($query); |
3028 | - $sth->execute(array(':version' => $version)); |
|
3029 | - } catch(PDOException $e) { |
|
3030 | - return "error : ".$e->getMessage(); |
|
3031 | - } |
|
3032 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3033 | - if ($row['nb'] > 0) return true; |
|
3034 | - else return false; |
|
3028 | + $sth->execute(array(':version' => $version)); |
|
3029 | + } catch(PDOException $e) { |
|
3030 | + return "error : ".$e->getMessage(); |
|
3031 | + } |
|
3032 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3033 | + if ($row['nb'] > 0) return true; |
|
3034 | + else return false; |
|
3035 | 3035 | } |
3036 | 3036 | |
3037 | 3037 | public static function check_marine_identity_version($version) { |
@@ -3132,10 +3132,10 @@ discard block |
||
3132 | 3132 | try { |
3133 | 3133 | $Connection = new Connection(); |
3134 | 3134 | $sth = $Connection->db->prepare($query); |
3135 | - $sth->execute(array(':version' => $version)); |
|
3136 | - } catch(PDOException $e) { |
|
3137 | - return "error : ".$e->getMessage(); |
|
3138 | - } |
|
3135 | + $sth->execute(array(':version' => $version)); |
|
3136 | + } catch(PDOException $e) { |
|
3137 | + return "error : ".$e->getMessage(); |
|
3138 | + } |
|
3139 | 3139 | } |
3140 | 3140 | |
3141 | 3141 | public static function insert_marine_identity_version($version) { |
@@ -3172,13 +3172,13 @@ discard block |
||
3172 | 3172 | try { |
3173 | 3173 | $Connection = new Connection(); |
3174 | 3174 | $sth = $Connection->db->prepare($query); |
3175 | - $sth->execute(); |
|
3176 | - } catch(PDOException $e) { |
|
3177 | - return "error : ".$e->getMessage(); |
|
3178 | - } |
|
3179 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3180 | - if ($row['nb'] > 0) return false; |
|
3181 | - else return true; |
|
3175 | + $sth->execute(); |
|
3176 | + } catch(PDOException $e) { |
|
3177 | + return "error : ".$e->getMessage(); |
|
3178 | + } |
|
3179 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3180 | + if ($row['nb'] > 0) return false; |
|
3181 | + else return true; |
|
3182 | 3182 | } |
3183 | 3183 | |
3184 | 3184 | public static function insert_last_notam_update() { |
@@ -3187,10 +3187,10 @@ discard block |
||
3187 | 3187 | try { |
3188 | 3188 | $Connection = new Connection(); |
3189 | 3189 | $sth = $Connection->db->prepare($query); |
3190 | - $sth->execute(); |
|
3191 | - } catch(PDOException $e) { |
|
3192 | - return "error : ".$e->getMessage(); |
|
3193 | - } |
|
3190 | + $sth->execute(); |
|
3191 | + } catch(PDOException $e) { |
|
3192 | + return "error : ".$e->getMessage(); |
|
3193 | + } |
|
3194 | 3194 | } |
3195 | 3195 | |
3196 | 3196 | public static function check_last_airspace_update() { |
@@ -3203,13 +3203,13 @@ discard block |
||
3203 | 3203 | try { |
3204 | 3204 | $Connection = new Connection(); |
3205 | 3205 | $sth = $Connection->db->prepare($query); |
3206 | - $sth->execute(); |
|
3207 | - } catch(PDOException $e) { |
|
3208 | - return "error : ".$e->getMessage(); |
|
3209 | - } |
|
3210 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3211 | - if ($row['nb'] > 0) return false; |
|
3212 | - else return true; |
|
3206 | + $sth->execute(); |
|
3207 | + } catch(PDOException $e) { |
|
3208 | + return "error : ".$e->getMessage(); |
|
3209 | + } |
|
3210 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3211 | + if ($row['nb'] > 0) return false; |
|
3212 | + else return true; |
|
3213 | 3213 | } |
3214 | 3214 | |
3215 | 3215 | public static function insert_last_airspace_update() { |
@@ -3218,10 +3218,10 @@ discard block |
||
3218 | 3218 | try { |
3219 | 3219 | $Connection = new Connection(); |
3220 | 3220 | $sth = $Connection->db->prepare($query); |
3221 | - $sth->execute(); |
|
3222 | - } catch(PDOException $e) { |
|
3223 | - return "error : ".$e->getMessage(); |
|
3224 | - } |
|
3221 | + $sth->execute(); |
|
3222 | + } catch(PDOException $e) { |
|
3223 | + return "error : ".$e->getMessage(); |
|
3224 | + } |
|
3225 | 3225 | } |
3226 | 3226 | |
3227 | 3227 | public static function check_last_geoid_update() { |
@@ -3234,13 +3234,13 @@ discard block |
||
3234 | 3234 | try { |
3235 | 3235 | $Connection = new Connection(); |
3236 | 3236 | $sth = $Connection->db->prepare($query); |
3237 | - $sth->execute(); |
|
3238 | - } catch(PDOException $e) { |
|
3239 | - return "error : ".$e->getMessage(); |
|
3240 | - } |
|
3241 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3242 | - if ($row['nb'] > 0) return false; |
|
3243 | - else return true; |
|
3237 | + $sth->execute(); |
|
3238 | + } catch(PDOException $e) { |
|
3239 | + return "error : ".$e->getMessage(); |
|
3240 | + } |
|
3241 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3242 | + if ($row['nb'] > 0) return false; |
|
3243 | + else return true; |
|
3244 | 3244 | } |
3245 | 3245 | |
3246 | 3246 | public static function insert_last_geoid_update() { |
@@ -3249,10 +3249,10 @@ discard block |
||
3249 | 3249 | try { |
3250 | 3250 | $Connection = new Connection(); |
3251 | 3251 | $sth = $Connection->db->prepare($query); |
3252 | - $sth->execute(); |
|
3253 | - } catch(PDOException $e) { |
|
3254 | - return "error : ".$e->getMessage(); |
|
3255 | - } |
|
3252 | + $sth->execute(); |
|
3253 | + } catch(PDOException $e) { |
|
3254 | + return "error : ".$e->getMessage(); |
|
3255 | + } |
|
3256 | 3256 | } |
3257 | 3257 | |
3258 | 3258 | public static function check_last_owner_update() { |
@@ -3358,13 +3358,13 @@ discard block |
||
3358 | 3358 | try { |
3359 | 3359 | $Connection = new Connection(); |
3360 | 3360 | $sth = $Connection->db->prepare($query); |
3361 | - $sth->execute(); |
|
3362 | - } catch(PDOException $e) { |
|
3363 | - return "error : ".$e->getMessage(); |
|
3364 | - } |
|
3365 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3366 | - if ($row['nb'] > 0) return false; |
|
3367 | - else return true; |
|
3361 | + $sth->execute(); |
|
3362 | + } catch(PDOException $e) { |
|
3363 | + return "error : ".$e->getMessage(); |
|
3364 | + } |
|
3365 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3366 | + if ($row['nb'] > 0) return false; |
|
3367 | + else return true; |
|
3368 | 3368 | } |
3369 | 3369 | |
3370 | 3370 | public static function insert_last_schedules_update() { |
@@ -3544,10 +3544,10 @@ discard block |
||
3544 | 3544 | try { |
3545 | 3545 | $Connection = new Connection(); |
3546 | 3546 | $sth = $Connection->db->prepare($query); |
3547 | - $sth->execute(); |
|
3548 | - } catch(PDOException $e) { |
|
3549 | - return "error : ".$e->getMessage(); |
|
3550 | - } |
|
3547 | + $sth->execute(); |
|
3548 | + } catch(PDOException $e) { |
|
3549 | + return "error : ".$e->getMessage(); |
|
3550 | + } |
|
3551 | 3551 | } |
3552 | 3552 | public static function delete_duplicateowner() { |
3553 | 3553 | global $globalDBdriver; |
@@ -3559,10 +3559,10 @@ discard block |
||
3559 | 3559 | try { |
3560 | 3560 | $Connection = new Connection(); |
3561 | 3561 | $sth = $Connection->db->prepare($query); |
3562 | - $sth->execute(); |
|
3563 | - } catch(PDOException $e) { |
|
3564 | - return "error : ".$e->getMessage(); |
|
3565 | - } |
|
3562 | + $sth->execute(); |
|
3563 | + } catch(PDOException $e) { |
|
3564 | + return "error : ".$e->getMessage(); |
|
3565 | + } |
|
3566 | 3566 | } |
3567 | 3567 | |
3568 | 3568 | public static function update_all() { |
@@ -14,40 +14,40 @@ |
||
14 | 14 | { |
15 | 15 | $coords = explode(',',$_GET['coord']); |
16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
17 | - || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
17 | + || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
19 | 19 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords)); |
20 | 20 | } |
21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
22 | - || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
22 | + || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
23 | 23 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords)); |
24 | 24 | } |
25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
26 | - || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
26 | + || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
27 | 27 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords)); |
28 | 28 | } |
29 | 29 | |
30 | 30 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
31 | - || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
31 | + || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
32 | 32 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true)); |
33 | 33 | } |
34 | 34 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
35 | 35 | } else { |
36 | 36 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
37 | - || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
37 | + || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
38 | 38 | //$spotter_array = $Source->getAllLocationInfo(); |
39 | 39 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
40 | 40 | } |
41 | 41 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
42 | - || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
42 | + || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
43 | 43 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
44 | 44 | } |
45 | 45 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
46 | - || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
46 | + || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
47 | 47 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
48 | 48 | } |
49 | 49 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
50 | - || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
50 | + || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
51 | 51 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true)); |
52 | 52 | } |
53 | 53 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -106,44 +106,44 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * Gets all the spotter information based on a particular callsign |
|
111 | - * |
|
112 | - * @return Array the spotter information |
|
113 | - * |
|
114 | - */ |
|
115 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | - { |
|
109 | + /** |
|
110 | + * Gets all the spotter information based on a particular callsign |
|
111 | + * |
|
112 | + * @return Array the spotter information |
|
113 | + * |
|
114 | + */ |
|
115 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | + { |
|
117 | 117 | $Tracker = new Tracker($this->db); |
118 | - date_default_timezone_set('UTC'); |
|
118 | + date_default_timezone_set('UTC'); |
|
119 | 119 | |
120 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
120 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
125 | 125 | |
126 | - return $spotter_array; |
|
127 | - } |
|
126 | + return $spotter_array; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Gets last the spotter information based on a particular id |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
136 | - public function getLastArchiveTrackerDataById($id) |
|
137 | - { |
|
138 | - $Tracker = new Tracker($this->db); |
|
139 | - date_default_timezone_set('UTC'); |
|
140 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
130 | + /** |
|
131 | + * Gets last the spotter information based on a particular id |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | + public function getLastArchiveTrackerDataById($id) |
|
137 | + { |
|
138 | + $Tracker = new Tracker($this->db); |
|
139 | + date_default_timezone_set('UTC'); |
|
140 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | - /* |
|
146 | + /* |
|
147 | 147 | try { |
148 | 148 | $Connection = new Connection(); |
149 | 149 | $sth = Connection->$db->prepare($query); |
@@ -153,188 +153,188 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | - |
|
158 | - return $spotter_array; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Gets all the spotter information based on a particular id |
|
163 | - * |
|
164 | - * @return Array the spotter information |
|
165 | - * |
|
166 | - */ |
|
167 | - public function getAllArchiveTrackerDataById($id) |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | + |
|
158 | + return $spotter_array; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Gets all the spotter information based on a particular id |
|
163 | + * |
|
164 | + * @return Array the spotter information |
|
165 | + * |
|
166 | + */ |
|
167 | + public function getAllArchiveTrackerDataById($id) |
|
168 | 168 | { |
169 | - date_default_timezone_set('UTC'); |
|
170 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
169 | + date_default_timezone_set('UTC'); |
|
170 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':id' => $id)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo $e->getMessage(); |
|
180 | - die; |
|
181 | - } |
|
182 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | - |
|
184 | - return $spotter_array; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Gets coordinate & time spotter information based on a particular id |
|
189 | - * |
|
190 | - * @return Array the spotter information |
|
191 | - * |
|
192 | - */ |
|
193 | - public function getCoordArchiveTrackerDataById($id) |
|
194 | - { |
|
195 | - date_default_timezone_set('UTC'); |
|
196 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':id' => $id)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo $e->getMessage(); |
|
180 | + die; |
|
181 | + } |
|
182 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | + |
|
184 | + return $spotter_array; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Gets coordinate & time spotter information based on a particular id |
|
189 | + * |
|
190 | + * @return Array the spotter information |
|
191 | + * |
|
192 | + */ |
|
193 | + public function getCoordArchiveTrackerDataById($id) |
|
194 | + { |
|
195 | + date_default_timezone_set('UTC'); |
|
196 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':id' => $id)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo $e->getMessage(); |
|
206 | - die; |
|
207 | - } |
|
208 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':id' => $id)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo $e->getMessage(); |
|
206 | + die; |
|
207 | + } |
|
208 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
209 | 209 | |
210 | - return $spotter_array; |
|
211 | - } |
|
210 | + return $spotter_array; |
|
211 | + } |
|
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Gets altitude information based on a particular callsign |
|
216 | - * |
|
217 | - * @return Array the spotter information |
|
218 | - * |
|
219 | - */ |
|
220 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | - { |
|
214 | + /** |
|
215 | + * Gets altitude information based on a particular callsign |
|
216 | + * |
|
217 | + * @return Array the spotter information |
|
218 | + * |
|
219 | + */ |
|
220 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | + { |
|
222 | 222 | |
223 | - date_default_timezone_set('UTC'); |
|
223 | + date_default_timezone_set('UTC'); |
|
224 | 224 | |
225 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
225 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | - try { |
|
229 | - $sth = $this->db->prepare($query); |
|
230 | - $sth->execute(array(':ident' => $ident)); |
|
231 | - } catch(PDOException $e) { |
|
232 | - echo $e->getMessage(); |
|
233 | - die; |
|
234 | - } |
|
235 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + try { |
|
229 | + $sth = $this->db->prepare($query); |
|
230 | + $sth->execute(array(':ident' => $ident)); |
|
231 | + } catch(PDOException $e) { |
|
232 | + echo $e->getMessage(); |
|
233 | + die; |
|
234 | + } |
|
235 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
236 | 236 | |
237 | - return $spotter_array; |
|
238 | - } |
|
237 | + return $spotter_array; |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Gets altitude information based on a particular id |
|
242 | - * |
|
243 | - * @return Array the spotter information |
|
244 | - * |
|
245 | - */ |
|
246 | - public function getAltitudeArchiveTrackerDataById($id) |
|
247 | - { |
|
240 | + /** |
|
241 | + * Gets altitude information based on a particular id |
|
242 | + * |
|
243 | + * @return Array the spotter information |
|
244 | + * |
|
245 | + */ |
|
246 | + public function getAltitudeArchiveTrackerDataById($id) |
|
247 | + { |
|
248 | 248 | |
249 | - date_default_timezone_set('UTC'); |
|
249 | + date_default_timezone_set('UTC'); |
|
250 | 250 | |
251 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
251 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | - try { |
|
255 | - $sth = $this->db->prepare($query); |
|
256 | - $sth->execute(array(':id' => $id)); |
|
257 | - } catch(PDOException $e) { |
|
258 | - echo $e->getMessage(); |
|
259 | - die; |
|
260 | - } |
|
261 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
254 | + try { |
|
255 | + $sth = $this->db->prepare($query); |
|
256 | + $sth->execute(array(':id' => $id)); |
|
257 | + } catch(PDOException $e) { |
|
258 | + echo $e->getMessage(); |
|
259 | + die; |
|
260 | + } |
|
261 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
262 | 262 | |
263 | - return $spotter_array; |
|
264 | - } |
|
263 | + return $spotter_array; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Gets altitude & speed information based on a particular id |
|
268 | - * |
|
269 | - * @return Array the spotter information |
|
270 | - * |
|
271 | - */ |
|
272 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | - { |
|
266 | + /** |
|
267 | + * Gets altitude & speed information based on a particular id |
|
268 | + * |
|
269 | + * @return Array the spotter information |
|
270 | + * |
|
271 | + */ |
|
272 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | + { |
|
274 | 274 | |
275 | - date_default_timezone_set('UTC'); |
|
275 | + date_default_timezone_set('UTC'); |
|
276 | 276 | |
277 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
277 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | - try { |
|
281 | - $sth = $this->db->prepare($query); |
|
282 | - $sth->execute(array(':id' => $id)); |
|
283 | - } catch(PDOException $e) { |
|
284 | - echo $e->getMessage(); |
|
285 | - die; |
|
286 | - } |
|
287 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
280 | + try { |
|
281 | + $sth = $this->db->prepare($query); |
|
282 | + $sth->execute(array(':id' => $id)); |
|
283 | + } catch(PDOException $e) { |
|
284 | + echo $e->getMessage(); |
|
285 | + die; |
|
286 | + } |
|
287 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
288 | 288 | |
289 | - return $spotter_array; |
|
290 | - } |
|
289 | + return $spotter_array; |
|
290 | + } |
|
291 | 291 | |
292 | 292 | |
293 | - /** |
|
294 | - * Gets altitude information based on a particular callsign |
|
295 | - * |
|
296 | - * @return Array the spotter information |
|
297 | - * |
|
298 | - */ |
|
299 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | - { |
|
293 | + /** |
|
294 | + * Gets altitude information based on a particular callsign |
|
295 | + * |
|
296 | + * @return Array the spotter information |
|
297 | + * |
|
298 | + */ |
|
299 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | + { |
|
301 | 301 | |
302 | - date_default_timezone_set('UTC'); |
|
302 | + date_default_timezone_set('UTC'); |
|
303 | 303 | |
304 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
304 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | - try { |
|
309 | - $sth = $this->db->prepare($query); |
|
310 | - $sth->execute(array(':ident' => $ident)); |
|
311 | - } catch(PDOException $e) { |
|
312 | - echo $e->getMessage(); |
|
313 | - die; |
|
314 | - } |
|
315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | + try { |
|
309 | + $sth = $this->db->prepare($query); |
|
310 | + $sth->execute(array(':ident' => $ident)); |
|
311 | + } catch(PDOException $e) { |
|
312 | + echo $e->getMessage(); |
|
313 | + die; |
|
314 | + } |
|
315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
316 | 316 | |
317 | - return $spotter_array; |
|
318 | - } |
|
317 | + return $spotter_array; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | 321 | |
322 | - /** |
|
323 | - * Gets all the archive spotter information |
|
324 | - * |
|
325 | - * @return Array the spotter information |
|
326 | - * |
|
327 | - */ |
|
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | - { |
|
330 | - $Tracker = new Tracker($this->db); |
|
331 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
322 | + /** |
|
323 | + * Gets all the archive spotter information |
|
324 | + * |
|
325 | + * @return Array the spotter information |
|
326 | + * |
|
327 | + */ |
|
328 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | + { |
|
330 | + $Tracker = new Tracker($this->db); |
|
331 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
335 | 335 | |
336 | - return $spotter_array; |
|
337 | - } |
|
336 | + return $spotter_array; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public function deleteTrackerArchiveTrackData() |
340 | 340 | { |
@@ -354,34 +354,34 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Gets Minimal Live Tracker data |
|
358 | - * |
|
359 | - * @return Array the spotter information |
|
360 | - * |
|
361 | - */ |
|
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | - { |
|
364 | - global $globalDBdriver, $globalLiveInterval; |
|
365 | - date_default_timezone_set('UTC'); |
|
366 | - |
|
367 | - $filter_query = ''; |
|
368 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | - } |
|
371 | - // Use spotter_output also ? |
|
372 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | - } |
|
375 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | - } |
|
378 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | - } |
|
357 | + * Gets Minimal Live Tracker data |
|
358 | + * |
|
359 | + * @return Array the spotter information |
|
360 | + * |
|
361 | + */ |
|
362 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | + { |
|
364 | + global $globalDBdriver, $globalLiveInterval; |
|
365 | + date_default_timezone_set('UTC'); |
|
381 | 366 | |
382 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | - if ($globalDBdriver == 'mysql') { |
|
384 | - /* |
|
367 | + $filter_query = ''; |
|
368 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | + } |
|
371 | + // Use spotter_output also ? |
|
372 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | + } |
|
375 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | + } |
|
378 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | + } |
|
381 | + |
|
382 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | + if ($globalDBdriver == 'mysql') { |
|
384 | + /* |
|
385 | 385 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
386 | 386 | FROM tracker_archive |
387 | 387 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | - } else { |
|
404 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | + } else { |
|
404 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
409 | 409 | '.$filter_query.' ORDER BY famtrackid'; |
410 | - } |
|
411 | - //echo $query; |
|
412 | - try { |
|
413 | - $sth = $this->db->prepare($query); |
|
414 | - $sth->execute(); |
|
415 | - } catch(PDOException $e) { |
|
416 | - echo $e->getMessage(); |
|
417 | - die; |
|
418 | - } |
|
419 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
410 | + } |
|
411 | + //echo $query; |
|
412 | + try { |
|
413 | + $sth = $this->db->prepare($query); |
|
414 | + $sth->execute(); |
|
415 | + } catch(PDOException $e) { |
|
416 | + echo $e->getMessage(); |
|
417 | + die; |
|
418 | + } |
|
419 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
420 | 420 | |
421 | - return $spotter_array; |
|
422 | - } |
|
421 | + return $spotter_array; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | /** |
425 | - * Gets Minimal Live Tracker data |
|
426 | - * |
|
427 | - * @return Array the spotter information |
|
428 | - * |
|
429 | - */ |
|
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | - { |
|
432 | - global $globalDBdriver, $globalLiveInterval; |
|
433 | - date_default_timezone_set('UTC'); |
|
434 | - |
|
435 | - $filter_query = ''; |
|
436 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | - } |
|
439 | - // Should use spotter_output also ? |
|
440 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | - } |
|
443 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | - } |
|
446 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | - } |
|
425 | + * Gets Minimal Live Tracker data |
|
426 | + * |
|
427 | + * @return Array the spotter information |
|
428 | + * |
|
429 | + */ |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | + { |
|
432 | + global $globalDBdriver, $globalLiveInterval; |
|
433 | + date_default_timezone_set('UTC'); |
|
434 | + |
|
435 | + $filter_query = ''; |
|
436 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | + } |
|
439 | + // Should use spotter_output also ? |
|
440 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | + } |
|
443 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | + } |
|
446 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | + } |
|
449 | 449 | |
450 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | - if ($globalDBdriver == 'mysql') { |
|
452 | - /* |
|
450 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | + if ($globalDBdriver == 'mysql') { |
|
452 | + /* |
|
453 | 453 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -460,95 +460,95 @@ discard block |
||
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
461 | 461 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
462 | 462 | |
463 | - } else { |
|
464 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | - /* |
|
463 | + } else { |
|
464 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | + /* |
|
466 | 466 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
467 | 467 | FROM tracker_archive_output |
468 | 468 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
477 | 477 | // .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
478 | 478 | |
479 | - } |
|
480 | - //echo $query; |
|
481 | - try { |
|
482 | - $sth = $this->db->prepare($query); |
|
483 | - $sth->execute(); |
|
484 | - } catch(PDOException $e) { |
|
485 | - echo $e->getMessage(); |
|
486 | - die; |
|
487 | - } |
|
488 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
479 | + } |
|
480 | + //echo $query; |
|
481 | + try { |
|
482 | + $sth = $this->db->prepare($query); |
|
483 | + $sth->execute(); |
|
484 | + } catch(PDOException $e) { |
|
485 | + echo $e->getMessage(); |
|
486 | + die; |
|
487 | + } |
|
488 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
489 | 489 | |
490 | - return $spotter_array; |
|
491 | - } |
|
490 | + return $spotter_array; |
|
491 | + } |
|
492 | 492 | |
493 | 493 | /** |
494 | - * Gets count Live Tracker data |
|
495 | - * |
|
496 | - * @return Array the spotter information |
|
497 | - * |
|
498 | - */ |
|
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | - { |
|
501 | - global $globalDBdriver, $globalLiveInterval; |
|
502 | - date_default_timezone_set('UTC'); |
|
503 | - |
|
504 | - $filter_query = ''; |
|
505 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | - } |
|
508 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | - } |
|
511 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | - } |
|
514 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | - } |
|
494 | + * Gets count Live Tracker data |
|
495 | + * |
|
496 | + * @return Array the spotter information |
|
497 | + * |
|
498 | + */ |
|
499 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | + { |
|
501 | + global $globalDBdriver, $globalLiveInterval; |
|
502 | + date_default_timezone_set('UTC'); |
|
517 | 503 | |
518 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | - if ($globalDBdriver == 'mysql') { |
|
504 | + $filter_query = ''; |
|
505 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | + } |
|
508 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | + } |
|
511 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | + } |
|
514 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | + } |
|
517 | + |
|
518 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | + if ($globalDBdriver == 'mysql') { |
|
520 | 520 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
521 | 521 | FROM tracker_archive l |
522 | 522 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
523 | - } else { |
|
523 | + } else { |
|
524 | 524 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
525 | - } |
|
526 | - //echo $query; |
|
527 | - try { |
|
528 | - $sth = $this->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - echo $e->getMessage(); |
|
532 | - die; |
|
533 | - } |
|
525 | + } |
|
526 | + //echo $query; |
|
527 | + try { |
|
528 | + $sth = $this->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + echo $e->getMessage(); |
|
532 | + die; |
|
533 | + } |
|
534 | 534 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
535 | 535 | $sth->closeCursor(); |
536 | - return $result['nb']; |
|
536 | + return $result['nb']; |
|
537 | 537 | |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | |
541 | 541 | |
542 | 542 | // tracker_archive_output |
543 | 543 | |
544 | - /** |
|
545 | - * Gets all the spotter information |
|
546 | - * |
|
547 | - * @return Array the spotter information |
|
548 | - * |
|
549 | - */ |
|
550 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
551 | - { |
|
544 | + /** |
|
545 | + * Gets all the spotter information |
|
546 | + * |
|
547 | + * @return Array the spotter information |
|
548 | + * |
|
549 | + */ |
|
550 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
551 | + { |
|
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
554 | 554 | $Translation = new Translation($this->db); |
@@ -562,159 +562,159 @@ discard block |
||
562 | 562 | $filter_query = $this->getFilter($filters); |
563 | 563 | if ($q != "") |
564 | 564 | { |
565 | - if (!is_string($q)) |
|
566 | - { |
|
565 | + if (!is_string($q)) |
|
566 | + { |
|
567 | 567 | return false; |
568 | - } else { |
|
568 | + } else { |
|
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | 572 | foreach ($q_array as $q_item){ |
573 | - $additional_query .= " AND ("; |
|
574 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | - $translate = $Translation->ident2icao($q_item); |
|
595 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | - $additional_query .= ")"; |
|
573 | + $additional_query .= " AND ("; |
|
574 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | + $translate = $Translation->ident2icao($q_item); |
|
595 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | + $additional_query .= ")"; |
|
598 | + } |
|
598 | 599 | } |
599 | - } |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | - if (!is_string($registration)) |
|
606 | - { |
|
604 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | + if (!is_string($registration)) |
|
606 | + { |
|
607 | 607 | return false; |
608 | - } else { |
|
608 | + } else { |
|
609 | 609 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
610 | - } |
|
610 | + } |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | - if (!is_string($aircraft_icao)) |
|
617 | - { |
|
615 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | + if (!is_string($aircraft_icao)) |
|
617 | + { |
|
618 | 618 | return false; |
619 | - } else { |
|
619 | + } else { |
|
620 | 620 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | - if (!is_string($aircraft_manufacturer)) |
|
628 | - { |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | + if (!is_string($aircraft_manufacturer)) |
|
628 | + { |
|
629 | 629 | return false; |
630 | - } else { |
|
630 | + } else { |
|
631 | 631 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | if ($highlights == "true") |
636 | 636 | { |
637 | - if (!is_string($highlights)) |
|
638 | - { |
|
637 | + if (!is_string($highlights)) |
|
638 | + { |
|
639 | 639 | return false; |
640 | - } else { |
|
640 | + } else { |
|
641 | 641 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
642 | - } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($airline_icao)) |
|
649 | - { |
|
647 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($airline_icao)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($airline_country)) |
|
660 | - { |
|
658 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($airline_country)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($airline_type)) |
|
671 | - { |
|
669 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($airline_type)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | if ($airline_type == "passenger") |
675 | 675 | { |
676 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
676 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
677 | 677 | } |
678 | 678 | if ($airline_type == "cargo") |
679 | 679 | { |
680 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
680 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
681 | 681 | } |
682 | 682 | if ($airline_type == "military") |
683 | 683 | { |
684 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
684 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
685 | + } |
|
685 | 686 | } |
686 | - } |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | - if (!is_string($airport)) |
|
693 | - { |
|
691 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | + if (!is_string($airport)) |
|
693 | + { |
|
694 | 694 | return false; |
695 | - } else { |
|
695 | + } else { |
|
696 | 696 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
697 | - } |
|
697 | + } |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | - if (!is_string($airport_country)) |
|
704 | - { |
|
702 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | + if (!is_string($airport_country)) |
|
704 | + { |
|
705 | 705 | return false; |
706 | - } else { |
|
706 | + } else { |
|
707 | 707 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
708 | - } |
|
708 | + } |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | - if (!is_string($callsign)) |
|
715 | - { |
|
713 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | + if (!is_string($callsign)) |
|
715 | + { |
|
716 | 716 | return false; |
717 | - } else { |
|
717 | + } else { |
|
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -722,99 +722,99 @@ discard block |
||
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
725 | - } |
|
725 | + } |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | - if (!is_string($owner)) |
|
732 | - { |
|
730 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | + if (!is_string($owner)) |
|
732 | + { |
|
733 | 733 | return false; |
734 | - } else { |
|
734 | + } else { |
|
735 | 735 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
736 | - } |
|
736 | + } |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | - if (!is_string($pilot_name)) |
|
743 | - { |
|
741 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | + if (!is_string($pilot_name)) |
|
743 | + { |
|
744 | 744 | return false; |
745 | - } else { |
|
745 | + } else { |
|
746 | 746 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
747 | - } |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | - if (!is_string($pilot_id)) |
|
754 | - { |
|
752 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | + if (!is_string($pilot_id)) |
|
754 | + { |
|
755 | 755 | return false; |
756 | - } else { |
|
756 | + } else { |
|
757 | 757 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
758 | - } |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | - if (!is_string($departure_airport_route)) |
|
765 | - { |
|
763 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | + if (!is_string($departure_airport_route)) |
|
765 | + { |
|
766 | 766 | return false; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
769 | - } |
|
769 | + } |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | - if (!is_string($arrival_airport_route)) |
|
776 | - { |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | + if (!is_string($arrival_airport_route)) |
|
776 | + { |
|
777 | 777 | return false; |
778 | - } else { |
|
778 | + } else { |
|
779 | 779 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
780 | - } |
|
780 | + } |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | if ($altitude != "") |
784 | 784 | { |
785 | - $altitude_array = explode(",", $altitude); |
|
785 | + $altitude_array = explode(",", $altitude); |
|
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | - if ($altitude_array[1] != "") |
|
792 | - { |
|
791 | + if ($altitude_array[1] != "") |
|
792 | + { |
|
793 | 793 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
794 | 794 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
795 | 795 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
796 | - } else { |
|
796 | + } else { |
|
797 | 797 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
798 | 798 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
799 | - } |
|
799 | + } |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | if ($date_posted != "") |
803 | 803 | { |
804 | - $date_array = explode(",", $date_posted); |
|
804 | + $date_array = explode(",", $date_posted); |
|
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | - if ($globalTimezone != '') { |
|
809 | + if ($globalTimezone != '') { |
|
810 | 810 | date_default_timezone_set($globalTimezone); |
811 | 811 | $datetime = new DateTime(); |
812 | 812 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
813 | + } else $offset = '+00:00'; |
|
814 | 814 | |
815 | 815 | |
816 | - if ($date_array[1] != "") |
|
817 | - { |
|
816 | + if ($date_array[1] != "") |
|
817 | + { |
|
818 | 818 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
819 | 819 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
820 | 820 | if ($globalDBdriver == 'mysql') { |
@@ -822,28 +822,28 @@ discard block |
||
822 | 822 | } else { |
823 | 823 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
824 | 824 | } |
825 | - } else { |
|
825 | + } else { |
|
826 | 826 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
827 | - if ($globalDBdriver == 'mysql') { |
|
827 | + if ($globalDBdriver == 'mysql') { |
|
828 | 828 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
829 | 829 | } else { |
830 | 830 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
831 | 831 | } |
832 | - } |
|
832 | + } |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | if ($limit != "") |
836 | 836 | { |
837 | - $limit_array = explode(",", $limit); |
|
837 | + $limit_array = explode(",", $limit); |
|
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | - { |
|
842 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | + { |
|
844 | 844 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
845 | 845 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
846 | - } |
|
846 | + } |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -874,33 +874,33 @@ discard block |
||
874 | 874 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - public function deleteTrackerArchiveData() |
|
880 | - { |
|
879 | + public function deleteTrackerArchiveData() |
|
880 | + { |
|
881 | 881 | global $globalArchiveKeepMonths, $globalDBdriver; |
882 | - date_default_timezone_set('UTC'); |
|
883 | - if ($globalDBdriver == 'mysql') { |
|
882 | + date_default_timezone_set('UTC'); |
|
883 | + if ($globalDBdriver == 'mysql') { |
|
884 | 884 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
885 | 885 | } else { |
886 | 886 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
887 | 887 | } |
888 | - try { |
|
889 | - $sth = $this->db->prepare($query); |
|
890 | - $sth->execute(); |
|
891 | - } catch(PDOException $e) { |
|
892 | - return "error"; |
|
893 | - } |
|
888 | + try { |
|
889 | + $sth = $this->db->prepare($query); |
|
890 | + $sth->execute(); |
|
891 | + } catch(PDOException $e) { |
|
892 | + return "error"; |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | - /** |
|
897 | - * Gets all the spotter information based on the callsign |
|
898 | - * |
|
899 | - * @return Array the spotter information |
|
900 | - * |
|
901 | - */ |
|
902 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | - { |
|
896 | + /** |
|
897 | + * Gets all the spotter information based on the callsign |
|
898 | + * |
|
899 | + * @return Array the spotter information |
|
900 | + * |
|
901 | + */ |
|
902 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | + { |
|
904 | 904 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
905 | 905 | |
906 | 906 | date_default_timezone_set('UTC'); |
@@ -912,35 +912,35 @@ discard block |
||
912 | 912 | |
913 | 913 | if ($ident != "") |
914 | 914 | { |
915 | - if (!is_string($ident)) |
|
916 | - { |
|
915 | + if (!is_string($ident)) |
|
916 | + { |
|
917 | 917 | return false; |
918 | - } else { |
|
918 | + } else { |
|
919 | 919 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
920 | 920 | $query_values = array(':ident' => $ident); |
921 | - } |
|
921 | + } |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | if ($limit != "") |
925 | 925 | { |
926 | - $limit_array = explode(",", $limit); |
|
926 | + $limit_array = explode(",", $limit); |
|
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | - { |
|
931 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | + { |
|
933 | 933 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
934 | 934 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | if ($sort != "") |
939 | 939 | { |
940 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
940 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
942 | 942 | } else { |
943 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
943 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -948,17 +948,17 @@ discard block |
||
948 | 948 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
949 | 949 | |
950 | 950 | return $spotter_array; |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | |
954 | - /** |
|
955 | - * Gets all the spotter information based on the owner |
|
956 | - * |
|
957 | - * @return Array the spotter information |
|
958 | - * |
|
959 | - */ |
|
960 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | - { |
|
954 | + /** |
|
955 | + * Gets all the spotter information based on the owner |
|
956 | + * |
|
957 | + * @return Array the spotter information |
|
958 | + * |
|
959 | + */ |
|
960 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | + { |
|
962 | 962 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
963 | 963 | |
964 | 964 | date_default_timezone_set('UTC'); |
@@ -971,35 +971,35 @@ discard block |
||
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
974 | - if (!is_string($owner)) |
|
975 | - { |
|
974 | + if (!is_string($owner)) |
|
975 | + { |
|
976 | 976 | return false; |
977 | - } else { |
|
977 | + } else { |
|
978 | 978 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
979 | 979 | $query_values = array(':owner' => $owner); |
980 | - } |
|
980 | + } |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | if ($limit != "") |
984 | 984 | { |
985 | - $limit_array = explode(",", $limit); |
|
985 | + $limit_array = explode(",", $limit); |
|
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | - { |
|
990 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | + { |
|
992 | 992 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
993 | 993 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
994 | - } |
|
994 | + } |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | if ($sort != "") |
998 | 998 | { |
999 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
999 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1001 | 1001 | } else { |
1002 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1002 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1007,16 +1007,16 @@ discard block |
||
1007 | 1007 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1008 | 1008 | |
1009 | 1009 | return $spotter_array; |
1010 | - } |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * Gets all the spotter information based on the pilot |
|
1014 | - * |
|
1015 | - * @return Array the spotter information |
|
1016 | - * |
|
1017 | - */ |
|
1018 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | - { |
|
1010 | + } |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * Gets all the spotter information based on the pilot |
|
1014 | + * |
|
1015 | + * @return Array the spotter information |
|
1016 | + * |
|
1017 | + */ |
|
1018 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | + { |
|
1020 | 1020 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
1021 | 1021 | |
1022 | 1022 | date_default_timezone_set('UTC'); |
@@ -1035,24 +1035,24 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | if ($limit != "") |
1037 | 1037 | { |
1038 | - $limit_array = explode(",", $limit); |
|
1038 | + $limit_array = explode(",", $limit); |
|
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | - { |
|
1043 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | + { |
|
1045 | 1045 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1046 | 1046 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | if ($sort != "") |
1051 | 1051 | { |
1052 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1052 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1054 | 1054 | } else { |
1055 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1055 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1060,16 +1060,16 @@ discard block |
||
1060 | 1060 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1061 | 1061 | |
1062 | 1062 | return $spotter_array; |
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Gets all number of flight over countries |
|
1067 | - * |
|
1068 | - * @return Array the airline country list |
|
1069 | - * |
|
1070 | - */ |
|
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | - { |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Gets all number of flight over countries |
|
1067 | + * |
|
1068 | + * @return Array the airline country list |
|
1069 | + * |
|
1070 | + */ |
|
1071 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | + { |
|
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
1075 | 1075 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1079,14 +1079,14 @@ discard block |
||
1079 | 1079 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1080 | 1080 | FROM countries c, tracker_archive s |
1081 | 1081 | WHERE c.iso2 = s.over_country "; |
1082 | - if ($olderthanmonths > 0) { |
|
1083 | - if ($globalDBdriver == 'mysql') { |
|
1082 | + if ($olderthanmonths > 0) { |
|
1083 | + if ($globalDBdriver == 'mysql') { |
|
1084 | 1084 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1085 | 1085 | } else { |
1086 | 1086 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1087 | 1087 | } |
1088 | 1088 | } |
1089 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1089 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | 1090 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1091 | 1091 | if ($limit) $query .= " LIMIT 0,10"; |
1092 | 1092 | |
@@ -1099,23 +1099,23 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1101 | 1101 | { |
1102 | - $temp_array['flight_count'] = $row['nb']; |
|
1103 | - $temp_array['flight_country'] = $row['name']; |
|
1104 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | - $flight_array[] = $temp_array; |
|
1102 | + $temp_array['flight_count'] = $row['nb']; |
|
1103 | + $temp_array['flight_country'] = $row['name']; |
|
1104 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | + $flight_array[] = $temp_array; |
|
1107 | 1107 | } |
1108 | 1108 | return $flight_array; |
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Gets all number of flight over countries |
|
1113 | - * |
|
1114 | - * @return Array the airline country list |
|
1115 | - * |
|
1116 | - */ |
|
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | - { |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Gets all number of flight over countries |
|
1113 | + * |
|
1114 | + * @return Array the airline country list |
|
1115 | + * |
|
1116 | + */ |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | + { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1125,14 +1125,14 @@ discard block |
||
1125 | 1125 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1126 | 1126 | FROM countries c, tracker_archive s, spotter_output o |
1127 | 1127 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
1128 | - if ($olderthanmonths > 0) { |
|
1129 | - if ($globalDBdriver == 'mysql') { |
|
1128 | + if ($olderthanmonths > 0) { |
|
1129 | + if ($globalDBdriver == 'mysql') { |
|
1130 | 1130 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1131 | 1131 | } else { |
1132 | 1132 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1135 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | 1136 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | 1137 | if ($limit) $query .= " LIMIT 0,10"; |
1138 | 1138 | |
@@ -1145,24 +1145,24 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1147 | 1147 | { |
1148 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | - $temp_array['flight_count'] = $row['nb']; |
|
1150 | - $temp_array['flight_country'] = $row['name']; |
|
1151 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | - $flight_array[] = $temp_array; |
|
1148 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | + $temp_array['flight_count'] = $row['nb']; |
|
1150 | + $temp_array['flight_country'] = $row['name']; |
|
1151 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | + $flight_array[] = $temp_array; |
|
1154 | 1154 | } |
1155 | 1155 | return $flight_array; |
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * Gets last spotter information based on a particular callsign |
|
1160 | - * |
|
1161 | - * @return Array the spotter information |
|
1162 | - * |
|
1163 | - */ |
|
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | - { |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * Gets last spotter information based on a particular callsign |
|
1160 | + * |
|
1161 | + * @return Array the spotter information |
|
1162 | + * |
|
1163 | + */ |
|
1164 | + public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | + { |
|
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1170,16 +1170,16 @@ discard block |
||
1170 | 1170 | $date = date('c',$date); |
1171 | 1171 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1172 | 1172 | return $spotter_array; |
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * Gets all the spotter information based on a particular callsign |
|
1177 | - * |
|
1178 | - * @return Array the spotter information |
|
1179 | - * |
|
1180 | - */ |
|
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | - { |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * Gets all the spotter information based on a particular callsign |
|
1177 | + * |
|
1178 | + * @return Array the spotter information |
|
1179 | + * |
|
1180 | + */ |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | + { |
|
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1187,16 +1187,16 @@ discard block |
||
1187 | 1187 | $date = date('c',$date); |
1188 | 1188 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1189 | 1189 | return $spotter_array; |
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * Gets all the spotter information based on the airport |
|
1194 | - * |
|
1195 | - * @return Array the spotter information |
|
1196 | - * |
|
1197 | - */ |
|
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | - { |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * Gets all the spotter information based on the airport |
|
1194 | + * |
|
1195 | + * @return Array the spotter information |
|
1196 | + * |
|
1197 | + */ |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | + { |
|
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
1202 | 1202 | date_default_timezone_set('UTC'); |
@@ -1207,35 +1207,35 @@ discard block |
||
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
1210 | - if (!is_string($airport)) |
|
1211 | - { |
|
1210 | + if (!is_string($airport)) |
|
1211 | + { |
|
1212 | 1212 | return false; |
1213 | - } else { |
|
1213 | + } else { |
|
1214 | 1214 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
1215 | 1215 | $query_values = array(':airport' => $airport); |
1216 | - } |
|
1216 | + } |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | if ($limit != "") |
1220 | 1220 | { |
1221 | - $limit_array = explode(",", $limit); |
|
1221 | + $limit_array = explode(",", $limit); |
|
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | - { |
|
1226 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | + { |
|
1228 | 1228 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1229 | 1229 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | if ($sort != "") |
1234 | 1234 | { |
1235 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1235 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1237 | 1237 | } else { |
1238 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1238 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1243,6 +1243,6 @@ discard block |
||
1243 | 1243 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1244 | 1244 | |
1245 | 1245 | return $spotter_array; |
1246 | - } |
|
1246 | + } |
|
1247 | 1247 | } |
1248 | 1248 | ?> |
1249 | 1249 | \ No newline at end of file |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * Gets all the spotter information based on a particular callsign |
|
115 | - * |
|
116 | - * @return Array the spotter information |
|
117 | - * |
|
118 | - */ |
|
119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
120 | - { |
|
113 | + /** |
|
114 | + * Gets all the spotter information based on a particular callsign |
|
115 | + * |
|
116 | + * @return Array the spotter information |
|
117 | + * |
|
118 | + */ |
|
119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
120 | + { |
|
121 | 121 | $Marine = new Marine($this->db); |
122 | - date_default_timezone_set('UTC'); |
|
122 | + date_default_timezone_set('UTC'); |
|
123 | 123 | |
124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
129 | 129 | |
130 | - return $spotter_array; |
|
131 | - } |
|
130 | + return $spotter_array; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * Gets last the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getLastArchiveMarineDataById($id) |
|
141 | - { |
|
142 | - $Marine = new Marine($this->db); |
|
143 | - date_default_timezone_set('UTC'); |
|
144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
134 | + /** |
|
135 | + * Gets last the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getLastArchiveMarineDataById($id) |
|
141 | + { |
|
142 | + $Marine = new Marine($this->db); |
|
143 | + date_default_timezone_set('UTC'); |
|
144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | - /* |
|
150 | + /* |
|
151 | 151 | try { |
152 | 152 | $Connection = new Connection(); |
153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,178 +157,178 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | - |
|
162 | - return $spotter_array; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Gets all the spotter information based on a particular id |
|
167 | - * |
|
168 | - * @return Array the spotter information |
|
169 | - * |
|
170 | - */ |
|
171 | - public function getAllArchiveMarineDataById($id) |
|
160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | + |
|
162 | + return $spotter_array; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Gets all the spotter information based on a particular id |
|
167 | + * |
|
168 | + * @return Array the spotter information |
|
169 | + * |
|
170 | + */ |
|
171 | + public function getAllArchiveMarineDataById($id) |
|
172 | 172 | { |
173 | - date_default_timezone_set('UTC'); |
|
174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + date_default_timezone_set('UTC'); |
|
174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | - try { |
|
180 | - $sth = $this->db->prepare($query); |
|
181 | - $sth->execute(array(':id' => $id)); |
|
182 | - } catch(PDOException $e) { |
|
183 | - echo $e->getMessage(); |
|
184 | - die; |
|
185 | - } |
|
186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | - |
|
188 | - return $spotter_array; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Gets coordinate & time spotter information based on a particular id |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
197 | - public function getCoordArchiveMarineDataById($id) |
|
198 | - { |
|
199 | - date_default_timezone_set('UTC'); |
|
200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
179 | + try { |
|
180 | + $sth = $this->db->prepare($query); |
|
181 | + $sth->execute(array(':id' => $id)); |
|
182 | + } catch(PDOException $e) { |
|
183 | + echo $e->getMessage(); |
|
184 | + die; |
|
185 | + } |
|
186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | + |
|
188 | + return $spotter_array; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Gets coordinate & time spotter information based on a particular id |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | + public function getCoordArchiveMarineDataById($id) |
|
198 | + { |
|
199 | + date_default_timezone_set('UTC'); |
|
200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':id' => $id)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo $e->getMessage(); |
|
210 | - die; |
|
211 | - } |
|
212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':id' => $id)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo $e->getMessage(); |
|
210 | + die; |
|
211 | + } |
|
212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
213 | 213 | |
214 | - return $spotter_array; |
|
215 | - } |
|
214 | + return $spotter_array; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets altitude information based on a particular callsign |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | - { |
|
218 | + /** |
|
219 | + * Gets altitude information based on a particular callsign |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | + { |
|
226 | 226 | |
227 | - date_default_timezone_set('UTC'); |
|
227 | + date_default_timezone_set('UTC'); |
|
228 | 228 | |
229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | - try { |
|
233 | - $sth = $this->db->prepare($query); |
|
234 | - $sth->execute(array(':ident' => $ident)); |
|
235 | - } catch(PDOException $e) { |
|
236 | - echo $e->getMessage(); |
|
237 | - die; |
|
238 | - } |
|
239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
232 | + try { |
|
233 | + $sth = $this->db->prepare($query); |
|
234 | + $sth->execute(array(':ident' => $ident)); |
|
235 | + } catch(PDOException $e) { |
|
236 | + echo $e->getMessage(); |
|
237 | + die; |
|
238 | + } |
|
239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
240 | 240 | |
241 | - return $spotter_array; |
|
242 | - } |
|
241 | + return $spotter_array; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Gets altitude information based on a particular id |
|
246 | - * |
|
247 | - * @return Array the spotter information |
|
248 | - * |
|
249 | - */ |
|
250 | - public function getAltitudeArchiveMarineDataById($id) |
|
251 | - { |
|
244 | + /** |
|
245 | + * Gets altitude information based on a particular id |
|
246 | + * |
|
247 | + * @return Array the spotter information |
|
248 | + * |
|
249 | + */ |
|
250 | + public function getAltitudeArchiveMarineDataById($id) |
|
251 | + { |
|
252 | 252 | |
253 | - date_default_timezone_set('UTC'); |
|
253 | + date_default_timezone_set('UTC'); |
|
254 | 254 | |
255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | - try { |
|
259 | - $sth = $this->db->prepare($query); |
|
260 | - $sth->execute(array(':id' => $id)); |
|
261 | - } catch(PDOException $e) { |
|
262 | - echo $e->getMessage(); |
|
263 | - die; |
|
264 | - } |
|
265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + try { |
|
259 | + $sth = $this->db->prepare($query); |
|
260 | + $sth->execute(array(':id' => $id)); |
|
261 | + } catch(PDOException $e) { |
|
262 | + echo $e->getMessage(); |
|
263 | + die; |
|
264 | + } |
|
265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
266 | 266 | |
267 | - return $spotter_array; |
|
268 | - } |
|
267 | + return $spotter_array; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Gets altitude & speed information based on a particular id |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Gets altitude & speed information based on a particular id |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | + { |
|
278 | 278 | |
279 | - date_default_timezone_set('UTC'); |
|
279 | + date_default_timezone_set('UTC'); |
|
280 | 280 | |
281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | - try { |
|
285 | - $sth = $this->db->prepare($query); |
|
286 | - $sth->execute(array(':id' => $id)); |
|
287 | - } catch(PDOException $e) { |
|
288 | - echo $e->getMessage(); |
|
289 | - die; |
|
290 | - } |
|
291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + try { |
|
285 | + $sth = $this->db->prepare($query); |
|
286 | + $sth->execute(array(':id' => $id)); |
|
287 | + } catch(PDOException $e) { |
|
288 | + echo $e->getMessage(); |
|
289 | + die; |
|
290 | + } |
|
291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
292 | 292 | |
293 | - return $spotter_array; |
|
294 | - } |
|
293 | + return $spotter_array; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * Gets altitude information based on a particular callsign |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | - { |
|
297 | + /** |
|
298 | + * Gets altitude information based on a particular callsign |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | + { |
|
305 | 305 | |
306 | - date_default_timezone_set('UTC'); |
|
306 | + date_default_timezone_set('UTC'); |
|
307 | 307 | |
308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | - try { |
|
313 | - $sth = $this->db->prepare($query); |
|
314 | - $sth->execute(array(':ident' => $ident)); |
|
315 | - } catch(PDOException $e) { |
|
316 | - echo $e->getMessage(); |
|
317 | - die; |
|
318 | - } |
|
319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
312 | + try { |
|
313 | + $sth = $this->db->prepare($query); |
|
314 | + $sth->execute(array(':ident' => $ident)); |
|
315 | + } catch(PDOException $e) { |
|
316 | + echo $e->getMessage(); |
|
317 | + die; |
|
318 | + } |
|
319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
320 | 320 | |
321 | - return $spotter_array; |
|
322 | - } |
|
321 | + return $spotter_array; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the archive spotter information |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getMarineArchiveData($ident,$fammarine_id,$date) |
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Delete all tracking data |
|
343 | - * |
|
344 | - */ |
|
341 | + /** |
|
342 | + * Delete all tracking data |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function deleteMarineArchiveTrackData() |
346 | 346 | { |
347 | 347 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
@@ -360,34 +360,34 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | - * Gets Minimal Live Marine data |
|
364 | - * |
|
365 | - * @return Array the spotter information |
|
366 | - * |
|
367 | - */ |
|
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | - { |
|
370 | - global $globalDBdriver, $globalLiveInterval; |
|
371 | - date_default_timezone_set('UTC'); |
|
372 | - |
|
373 | - $filter_query = ''; |
|
374 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | - } |
|
377 | - // Use spotter_output also ? |
|
378 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | - } |
|
381 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | - } |
|
384 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | - } |
|
363 | + * Gets Minimal Live Marine data |
|
364 | + * |
|
365 | + * @return Array the spotter information |
|
366 | + * |
|
367 | + */ |
|
368 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | + { |
|
370 | + global $globalDBdriver, $globalLiveInterval; |
|
371 | + date_default_timezone_set('UTC'); |
|
387 | 372 | |
388 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | - if ($globalDBdriver == 'mysql') { |
|
390 | - /* |
|
373 | + $filter_query = ''; |
|
374 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | + } |
|
377 | + // Use spotter_output also ? |
|
378 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | + } |
|
381 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | + } |
|
384 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | + } |
|
387 | + |
|
388 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | + if ($globalDBdriver == 'mysql') { |
|
390 | + /* |
|
391 | 391 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
392 | 392 | FROM marine_archive |
393 | 393 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -406,56 +406,56 @@ discard block |
||
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | - } else { |
|
410 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
409 | + } else { |
|
410 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
415 | 415 | '.$filter_query.' ORDER BY fammarine_id'; |
416 | - } |
|
417 | - //echo $query; |
|
418 | - try { |
|
419 | - $sth = $this->db->prepare($query); |
|
420 | - $sth->execute(); |
|
421 | - } catch(PDOException $e) { |
|
422 | - echo $e->getMessage(); |
|
423 | - die; |
|
424 | - } |
|
425 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
416 | + } |
|
417 | + //echo $query; |
|
418 | + try { |
|
419 | + $sth = $this->db->prepare($query); |
|
420 | + $sth->execute(); |
|
421 | + } catch(PDOException $e) { |
|
422 | + echo $e->getMessage(); |
|
423 | + die; |
|
424 | + } |
|
425 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
426 | 426 | |
427 | - return $spotter_array; |
|
428 | - } |
|
427 | + return $spotter_array; |
|
428 | + } |
|
429 | 429 | |
430 | 430 | /** |
431 | - * Gets Minimal Live Marine data |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | - { |
|
438 | - global $globalDBdriver, $globalLiveInterval; |
|
439 | - date_default_timezone_set('UTC'); |
|
440 | - |
|
441 | - $filter_query = ''; |
|
442 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | - } |
|
445 | - // Should use spotter_output also ? |
|
446 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | - } |
|
449 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | - } |
|
452 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | - } |
|
431 | + * Gets Minimal Live Marine data |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | + { |
|
438 | + global $globalDBdriver, $globalLiveInterval; |
|
439 | + date_default_timezone_set('UTC'); |
|
455 | 440 | |
456 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | - if ($globalDBdriver == 'mysql') { |
|
458 | - /* |
|
441 | + $filter_query = ''; |
|
442 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | + } |
|
445 | + // Should use spotter_output also ? |
|
446 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | + } |
|
449 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | + } |
|
452 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | + } |
|
455 | + |
|
456 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | + if ($globalDBdriver == 'mysql') { |
|
458 | + /* |
|
459 | 459 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -466,95 +466,95 @@ discard block |
||
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
467 | 467 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
468 | 468 | |
469 | - } else { |
|
470 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | - /* |
|
469 | + } else { |
|
470 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | + /* |
|
472 | 472 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
473 | 473 | FROM marine_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
482 | 482 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
483 | 483 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
484 | 484 | |
485 | - } |
|
486 | - //echo $query; |
|
487 | - try { |
|
488 | - $sth = $this->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - echo $e->getMessage(); |
|
492 | - die; |
|
493 | - } |
|
494 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
485 | + } |
|
486 | + //echo $query; |
|
487 | + try { |
|
488 | + $sth = $this->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + echo $e->getMessage(); |
|
492 | + die; |
|
493 | + } |
|
494 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | 495 | |
496 | - return $spotter_array; |
|
497 | - } |
|
496 | + return $spotter_array; |
|
497 | + } |
|
498 | 498 | |
499 | 499 | /** |
500 | - * Gets count Live Marine data |
|
501 | - * |
|
502 | - * @return Array the spotter information |
|
503 | - * |
|
504 | - */ |
|
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | - { |
|
507 | - global $globalDBdriver, $globalLiveInterval; |
|
508 | - date_default_timezone_set('UTC'); |
|
509 | - |
|
510 | - $filter_query = ''; |
|
511 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | - } |
|
514 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | - } |
|
517 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | - } |
|
520 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | - } |
|
500 | + * Gets count Live Marine data |
|
501 | + * |
|
502 | + * @return Array the spotter information |
|
503 | + * |
|
504 | + */ |
|
505 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | + { |
|
507 | + global $globalDBdriver, $globalLiveInterval; |
|
508 | + date_default_timezone_set('UTC'); |
|
523 | 509 | |
524 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | - if ($globalDBdriver == 'mysql') { |
|
510 | + $filter_query = ''; |
|
511 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | + } |
|
514 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | + } |
|
517 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | + } |
|
520 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | + } |
|
523 | + |
|
524 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | + if ($globalDBdriver == 'mysql') { |
|
526 | 526 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
527 | 527 | FROM marine_archive l |
528 | 528 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
529 | - } else { |
|
529 | + } else { |
|
530 | 530 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
531 | - } |
|
532 | - //echo $query; |
|
533 | - try { |
|
534 | - $sth = $this->db->prepare($query); |
|
535 | - $sth->execute(); |
|
536 | - } catch(PDOException $e) { |
|
537 | - echo $e->getMessage(); |
|
538 | - die; |
|
539 | - } |
|
531 | + } |
|
532 | + //echo $query; |
|
533 | + try { |
|
534 | + $sth = $this->db->prepare($query); |
|
535 | + $sth->execute(); |
|
536 | + } catch(PDOException $e) { |
|
537 | + echo $e->getMessage(); |
|
538 | + die; |
|
539 | + } |
|
540 | 540 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
541 | 541 | $sth->closeCursor(); |
542 | - return $result['nb']; |
|
542 | + return $result['nb']; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | 546 | |
547 | 547 | |
548 | 548 | // marine_archive_output |
549 | 549 | |
550 | - /** |
|
551 | - * Gets all the spotter information |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
556 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
557 | - { |
|
550 | + /** |
|
551 | + * Gets all the spotter information |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
557 | + { |
|
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
560 | 560 | $Translation = new Translation($this->db); |
@@ -568,159 +568,159 @@ discard block |
||
568 | 568 | $filter_query = $this->getFilter($filters); |
569 | 569 | if ($q != "") |
570 | 570 | { |
571 | - if (!is_string($q)) |
|
572 | - { |
|
571 | + if (!is_string($q)) |
|
572 | + { |
|
573 | 573 | return false; |
574 | - } else { |
|
574 | + } else { |
|
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | 578 | foreach ($q_array as $q_item){ |
579 | - $additional_query .= " AND ("; |
|
580 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | - $translate = $Translation->ident2icao($q_item); |
|
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | - $additional_query .= ")"; |
|
579 | + $additional_query .= " AND ("; |
|
580 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | + $translate = $Translation->ident2icao($q_item); |
|
601 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | + $additional_query .= ")"; |
|
604 | + } |
|
604 | 605 | } |
605 | - } |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | - if (!is_string($registration)) |
|
612 | - { |
|
610 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | + if (!is_string($registration)) |
|
612 | + { |
|
613 | 613 | return false; |
614 | - } else { |
|
614 | + } else { |
|
615 | 615 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
616 | - } |
|
616 | + } |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | - if (!is_string($aircraft_icao)) |
|
623 | - { |
|
621 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | + if (!is_string($aircraft_icao)) |
|
623 | + { |
|
624 | 624 | return false; |
625 | - } else { |
|
625 | + } else { |
|
626 | 626 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | - if (!is_string($aircraft_manufacturer)) |
|
634 | - { |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | + if (!is_string($aircraft_manufacturer)) |
|
634 | + { |
|
635 | 635 | return false; |
636 | - } else { |
|
636 | + } else { |
|
637 | 637 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
638 | - } |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if ($highlights == "true") |
642 | 642 | { |
643 | - if (!is_string($highlights)) |
|
644 | - { |
|
643 | + if (!is_string($highlights)) |
|
644 | + { |
|
645 | 645 | return false; |
646 | - } else { |
|
646 | + } else { |
|
647 | 647 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
648 | - } |
|
648 | + } |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | - if (!is_string($airline_icao)) |
|
655 | - { |
|
653 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | + if (!is_string($airline_icao)) |
|
655 | + { |
|
656 | 656 | return false; |
657 | - } else { |
|
657 | + } else { |
|
658 | 658 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
659 | - } |
|
659 | + } |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | - if (!is_string($airline_country)) |
|
666 | - { |
|
664 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | + if (!is_string($airline_country)) |
|
666 | + { |
|
667 | 667 | return false; |
668 | - } else { |
|
668 | + } else { |
|
669 | 669 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
670 | - } |
|
670 | + } |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | - if (!is_string($airline_type)) |
|
677 | - { |
|
675 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | + if (!is_string($airline_type)) |
|
677 | + { |
|
678 | 678 | return false; |
679 | - } else { |
|
679 | + } else { |
|
680 | 680 | if ($airline_type == "passenger") |
681 | 681 | { |
682 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
682 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
683 | 683 | } |
684 | 684 | if ($airline_type == "cargo") |
685 | 685 | { |
686 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
686 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
687 | 687 | } |
688 | 688 | if ($airline_type == "military") |
689 | 689 | { |
690 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
690 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
691 | + } |
|
691 | 692 | } |
692 | - } |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | - if (!is_string($airport)) |
|
699 | - { |
|
697 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | + if (!is_string($airport)) |
|
699 | + { |
|
700 | 700 | return false; |
701 | - } else { |
|
701 | + } else { |
|
702 | 702 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
703 | - } |
|
703 | + } |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | - if (!is_string($airport_country)) |
|
710 | - { |
|
708 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | + if (!is_string($airport_country)) |
|
710 | + { |
|
711 | 711 | return false; |
712 | - } else { |
|
712 | + } else { |
|
713 | 713 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
714 | - } |
|
714 | + } |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | - if (!is_string($callsign)) |
|
721 | - { |
|
719 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | + if (!is_string($callsign)) |
|
721 | + { |
|
722 | 722 | return false; |
723 | - } else { |
|
723 | + } else { |
|
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -728,99 +728,99 @@ discard block |
||
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | - if (!is_string($owner)) |
|
738 | - { |
|
736 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | + if (!is_string($owner)) |
|
738 | + { |
|
739 | 739 | return false; |
740 | - } else { |
|
740 | + } else { |
|
741 | 741 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
742 | - } |
|
742 | + } |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | - if (!is_string($pilot_name)) |
|
749 | - { |
|
747 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | + if (!is_string($pilot_name)) |
|
749 | + { |
|
750 | 750 | return false; |
751 | - } else { |
|
751 | + } else { |
|
752 | 752 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
753 | - } |
|
753 | + } |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | - if (!is_string($pilot_id)) |
|
760 | - { |
|
758 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | + if (!is_string($pilot_id)) |
|
760 | + { |
|
761 | 761 | return false; |
762 | - } else { |
|
762 | + } else { |
|
763 | 763 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
764 | - } |
|
764 | + } |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | - if (!is_string($departure_airport_route)) |
|
771 | - { |
|
769 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | + if (!is_string($departure_airport_route)) |
|
771 | + { |
|
772 | 772 | return false; |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
775 | - } |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | - if (!is_string($arrival_airport_route)) |
|
782 | - { |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | + if (!is_string($arrival_airport_route)) |
|
782 | + { |
|
783 | 783 | return false; |
784 | - } else { |
|
784 | + } else { |
|
785 | 785 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
786 | - } |
|
786 | + } |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ($altitude != "") |
790 | 790 | { |
791 | - $altitude_array = explode(",", $altitude); |
|
791 | + $altitude_array = explode(",", $altitude); |
|
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | - if ($altitude_array[1] != "") |
|
798 | - { |
|
797 | + if ($altitude_array[1] != "") |
|
798 | + { |
|
799 | 799 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
800 | 800 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
801 | 801 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
802 | - } else { |
|
802 | + } else { |
|
803 | 803 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
804 | 804 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
805 | - } |
|
805 | + } |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | if ($date_posted != "") |
809 | 809 | { |
810 | - $date_array = explode(",", $date_posted); |
|
810 | + $date_array = explode(",", $date_posted); |
|
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | - if ($globalTimezone != '') { |
|
815 | + if ($globalTimezone != '') { |
|
816 | 816 | date_default_timezone_set($globalTimezone); |
817 | 817 | $datetime = new DateTime(); |
818 | 818 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
819 | + } else $offset = '+00:00'; |
|
820 | 820 | |
821 | 821 | |
822 | - if ($date_array[1] != "") |
|
823 | - { |
|
822 | + if ($date_array[1] != "") |
|
823 | + { |
|
824 | 824 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
825 | 825 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
826 | 826 | if ($globalDBdriver == 'mysql') { |
@@ -828,28 +828,28 @@ discard block |
||
828 | 828 | } else { |
829 | 829 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
830 | 830 | } |
831 | - } else { |
|
831 | + } else { |
|
832 | 832 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
833 | - if ($globalDBdriver == 'mysql') { |
|
833 | + if ($globalDBdriver == 'mysql') { |
|
834 | 834 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
835 | 835 | } else { |
836 | 836 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
837 | 837 | } |
838 | - } |
|
838 | + } |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | if ($limit != "") |
842 | 842 | { |
843 | - $limit_array = explode(",", $limit); |
|
843 | + $limit_array = explode(",", $limit); |
|
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | - { |
|
848 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | + { |
|
850 | 850 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
851 | 851 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
852 | - } |
|
852 | + } |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
@@ -880,33 +880,33 @@ discard block |
||
880 | 880 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | - } |
|
883 | + } |
|
884 | 884 | |
885 | - public function deleteMarineArchiveData() |
|
886 | - { |
|
885 | + public function deleteMarineArchiveData() |
|
886 | + { |
|
887 | 887 | global $globalArchiveKeepMonths, $globalDBdriver; |
888 | - date_default_timezone_set('UTC'); |
|
889 | - if ($globalDBdriver == 'mysql') { |
|
888 | + date_default_timezone_set('UTC'); |
|
889 | + if ($globalDBdriver == 'mysql') { |
|
890 | 890 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
891 | 891 | } else { |
892 | 892 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
893 | 893 | } |
894 | - try { |
|
895 | - $sth = $this->db->prepare($query); |
|
896 | - $sth->execute(); |
|
897 | - } catch(PDOException $e) { |
|
898 | - return "error"; |
|
899 | - } |
|
894 | + try { |
|
895 | + $sth = $this->db->prepare($query); |
|
896 | + $sth->execute(); |
|
897 | + } catch(PDOException $e) { |
|
898 | + return "error"; |
|
899 | + } |
|
900 | 900 | } |
901 | 901 | |
902 | - /** |
|
903 | - * Gets all the spotter information based on the callsign |
|
904 | - * |
|
905 | - * @return Array the spotter information |
|
906 | - * |
|
907 | - */ |
|
908 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | - { |
|
902 | + /** |
|
903 | + * Gets all the spotter information based on the callsign |
|
904 | + * |
|
905 | + * @return Array the spotter information |
|
906 | + * |
|
907 | + */ |
|
908 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | + { |
|
910 | 910 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
911 | 911 | |
912 | 912 | date_default_timezone_set('UTC'); |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | |
919 | 919 | if ($ident != "") |
920 | 920 | { |
921 | - if (!is_string($ident)) |
|
922 | - { |
|
921 | + if (!is_string($ident)) |
|
922 | + { |
|
923 | 923 | return false; |
924 | - } else { |
|
924 | + } else { |
|
925 | 925 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
926 | 926 | $query_values = array(':ident' => $ident); |
927 | - } |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | if ($limit != "") |
931 | 931 | { |
932 | - $limit_array = explode(",", $limit); |
|
932 | + $limit_array = explode(",", $limit); |
|
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | - { |
|
937 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | + { |
|
939 | 939 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
940 | 940 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
941 | - } |
|
941 | + } |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($sort != "") |
945 | 945 | { |
946 | - $search_orderby_array = $Marine->getOrderBy(); |
|
947 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
946 | + $search_orderby_array = $Marine->getOrderBy(); |
|
947 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
948 | 948 | } else { |
949 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
949 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -954,17 +954,17 @@ discard block |
||
954 | 954 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
955 | 955 | |
956 | 956 | return $spotter_array; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | |
960 | - /** |
|
961 | - * Gets all the spotter information based on the owner |
|
962 | - * |
|
963 | - * @return Array the spotter information |
|
964 | - * |
|
965 | - */ |
|
966 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | - { |
|
960 | + /** |
|
961 | + * Gets all the spotter information based on the owner |
|
962 | + * |
|
963 | + * @return Array the spotter information |
|
964 | + * |
|
965 | + */ |
|
966 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | + { |
|
968 | 968 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
969 | 969 | |
970 | 970 | date_default_timezone_set('UTC'); |
@@ -977,35 +977,35 @@ discard block |
||
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
980 | - if (!is_string($owner)) |
|
981 | - { |
|
980 | + if (!is_string($owner)) |
|
981 | + { |
|
982 | 982 | return false; |
983 | - } else { |
|
983 | + } else { |
|
984 | 984 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
985 | 985 | $query_values = array(':owner' => $owner); |
986 | - } |
|
986 | + } |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | if ($limit != "") |
990 | 990 | { |
991 | - $limit_array = explode(",", $limit); |
|
991 | + $limit_array = explode(",", $limit); |
|
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | - { |
|
996 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | + { |
|
998 | 998 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
999 | 999 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1000 | - } |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if ($sort != "") |
1004 | 1004 | { |
1005 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1005 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1007 | 1007 | } else { |
1008 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1008 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1014 | 1014 | |
1015 | 1015 | return $spotter_array; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * Gets all the spotter information based on the pilot |
|
1020 | - * |
|
1021 | - * @return Array the spotter information |
|
1022 | - * |
|
1023 | - */ |
|
1024 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | - { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * Gets all the spotter information based on the pilot |
|
1020 | + * |
|
1021 | + * @return Array the spotter information |
|
1022 | + * |
|
1023 | + */ |
|
1024 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | + { |
|
1026 | 1026 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1027 | 1027 | |
1028 | 1028 | date_default_timezone_set('UTC'); |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | if ($limit != "") |
1043 | 1043 | { |
1044 | - $limit_array = explode(",", $limit); |
|
1044 | + $limit_array = explode(",", $limit); |
|
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | - { |
|
1049 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | + { |
|
1051 | 1051 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1052 | 1052 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1053 | - } |
|
1053 | + } |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | if ($sort != "") |
1057 | 1057 | { |
1058 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1058 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1060 | 1060 | } else { |
1061 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1061 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1066,16 +1066,16 @@ discard block |
||
1066 | 1066 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1067 | 1067 | |
1068 | 1068 | return $spotter_array; |
1069 | - } |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * Gets all number of flight over countries |
|
1073 | - * |
|
1074 | - * @return Array the airline country list |
|
1075 | - * |
|
1076 | - */ |
|
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | - { |
|
1069 | + } |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * Gets all number of flight over countries |
|
1073 | + * |
|
1074 | + * @return Array the airline country list |
|
1075 | + * |
|
1076 | + */ |
|
1077 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | + { |
|
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
1081 | 1081 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1086 | 1086 | FROM countries c, marine_archive s |
1087 | 1087 | WHERE c.iso2 = s.over_country "; |
1088 | - if ($olderthanmonths > 0) { |
|
1089 | - if ($globalDBdriver == 'mysql') { |
|
1088 | + if ($olderthanmonths > 0) { |
|
1089 | + if ($globalDBdriver == 'mysql') { |
|
1090 | 1090 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1091 | 1091 | } else { |
1092 | 1092 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1093 | } |
1094 | 1094 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1095 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1096 | 1096 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | 1097 | if ($limit) $query .= " LIMIT 0,10"; |
1098 | 1098 | |
@@ -1105,23 +1105,23 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1107 | 1107 | { |
1108 | - $temp_array['flight_count'] = $row['nb']; |
|
1109 | - $temp_array['flight_country'] = $row['name']; |
|
1110 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | - $flight_array[] = $temp_array; |
|
1108 | + $temp_array['flight_count'] = $row['nb']; |
|
1109 | + $temp_array['flight_country'] = $row['name']; |
|
1110 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | + $flight_array[] = $temp_array; |
|
1113 | 1113 | } |
1114 | 1114 | return $flight_array; |
1115 | - } |
|
1116 | - |
|
1117 | - /** |
|
1118 | - * Gets all number of flight over countries |
|
1119 | - * |
|
1120 | - * @return Array the airline country list |
|
1121 | - * |
|
1122 | - */ |
|
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | - { |
|
1115 | + } |
|
1116 | + |
|
1117 | + /** |
|
1118 | + * Gets all number of flight over countries |
|
1119 | + * |
|
1120 | + * @return Array the airline country list |
|
1121 | + * |
|
1122 | + */ |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | + { |
|
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
1127 | 1127 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1132 | 1132 | FROM countries c, marine_archive s, spotter_output o |
1133 | 1133 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1134 | - if ($olderthanmonths > 0) { |
|
1135 | - if ($globalDBdriver == 'mysql') { |
|
1134 | + if ($olderthanmonths > 0) { |
|
1135 | + if ($globalDBdriver == 'mysql') { |
|
1136 | 1136 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1137 | 1137 | } else { |
1138 | 1138 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1141 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1142 | 1142 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | 1143 | if ($limit) $query .= " LIMIT 0,10"; |
1144 | 1144 | |
@@ -1151,24 +1151,24 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1153 | 1153 | { |
1154 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | - $temp_array['flight_count'] = $row['nb']; |
|
1156 | - $temp_array['flight_country'] = $row['name']; |
|
1157 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | - $flight_array[] = $temp_array; |
|
1154 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | + $temp_array['flight_count'] = $row['nb']; |
|
1156 | + $temp_array['flight_country'] = $row['name']; |
|
1157 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | + $flight_array[] = $temp_array; |
|
1160 | 1160 | } |
1161 | 1161 | return $flight_array; |
1162 | - } |
|
1163 | - |
|
1164 | - /** |
|
1165 | - * Gets last spotter information based on a particular callsign |
|
1166 | - * |
|
1167 | - * @return Array the spotter information |
|
1168 | - * |
|
1169 | - */ |
|
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1171 | - { |
|
1162 | + } |
|
1163 | + |
|
1164 | + /** |
|
1165 | + * Gets last spotter information based on a particular callsign |
|
1166 | + * |
|
1167 | + * @return Array the spotter information |
|
1168 | + * |
|
1169 | + */ |
|
1170 | + public function getDateArchiveMarineDataById($id,$date) |
|
1171 | + { |
|
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1176,16 +1176,16 @@ discard block |
||
1176 | 1176 | $date = date('c',$date); |
1177 | 1177 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1178 | 1178 | return $spotter_array; |
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * Gets all the spotter information based on a particular callsign |
|
1183 | - * |
|
1184 | - * @return Array the spotter information |
|
1185 | - * |
|
1186 | - */ |
|
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | - { |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * Gets all the spotter information based on a particular callsign |
|
1183 | + * |
|
1184 | + * @return Array the spotter information |
|
1185 | + * |
|
1186 | + */ |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | + { |
|
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1193,16 +1193,16 @@ discard block |
||
1193 | 1193 | $date = date('c',$date); |
1194 | 1194 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1195 | 1195 | return $spotter_array; |
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * Gets all the spotter information based on the airport |
|
1200 | - * |
|
1201 | - * @return Array the spotter information |
|
1202 | - * |
|
1203 | - */ |
|
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | - { |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * Gets all the spotter information based on the airport |
|
1200 | + * |
|
1201 | + * @return Array the spotter information |
|
1202 | + * |
|
1203 | + */ |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | + { |
|
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
1208 | 1208 | date_default_timezone_set('UTC'); |
@@ -1213,35 +1213,35 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
1216 | - if (!is_string($airport)) |
|
1217 | - { |
|
1216 | + if (!is_string($airport)) |
|
1217 | + { |
|
1218 | 1218 | return false; |
1219 | - } else { |
|
1219 | + } else { |
|
1220 | 1220 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1221 | 1221 | $query_values = array(':airport' => $airport); |
1222 | - } |
|
1222 | + } |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | if ($limit != "") |
1226 | 1226 | { |
1227 | - $limit_array = explode(",", $limit); |
|
1227 | + $limit_array = explode(",", $limit); |
|
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | - { |
|
1232 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | + { |
|
1234 | 1234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1235 | 1235 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1236 | - } |
|
1236 | + } |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | if ($sort != "") |
1240 | 1240 | { |
1241 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1241 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1243 | 1243 | } else { |
1244 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1244 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1249,6 +1249,6 @@ discard block |
||
1249 | 1249 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1250 | 1250 | |
1251 | 1251 | return $spotter_array; |
1252 | - } |
|
1252 | + } |
|
1253 | 1253 | } |
1254 | 1254 | ?> |
1255 | 1255 | \ No newline at end of file |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | } |
555 | 555 | } |
556 | 556 | <?php |
557 | - } else { |
|
558 | - ?> |
|
557 | + } else { |
|
558 | + ?> |
|
559 | 559 | if (map.getZoom() > 7) { |
560 | 560 | var style = { |
561 | 561 | "color": "#1a3151", |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | layer_tracker_data.addLayer(layer); |
575 | 575 | } |
576 | 576 | <?php |
577 | - } |
|
577 | + } |
|
578 | 578 | ?> |
579 | 579 | } |
580 | 580 | } |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | $( document ).ready(function() { |
600 | 600 | map.on('moveend', function() { |
601 | 601 | <?php |
602 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
602 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
603 | 603 | ?> |
604 | 604 | getLiveTrackerData(1); |
605 | 605 | <?php |
606 | - } |
|
606 | + } |
|
607 | 607 | ?> |
608 | 608 | }); |
609 | 609 | //load the function on startup |