@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Gets all the spotter information based on the latest data entry |
|
100 | - * |
|
101 | - * @return Array the spotter information |
|
102 | - * |
|
103 | - */ |
|
99 | + * Gets all the spotter information based on the latest data entry |
|
100 | + * |
|
101 | + * @return Array the spotter information |
|
102 | + * |
|
103 | + */ |
|
104 | 104 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
105 | 105 | { |
106 | 106 | global $globalDBdriver, $globalLiveInterval; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | - * Gets Minimal Live Spotter data |
|
147 | - * |
|
148 | - * @return Array the spotter information |
|
149 | - * |
|
150 | - */ |
|
146 | + * Gets Minimal Live Spotter data |
|
147 | + * |
|
148 | + * @return Array the spotter information |
|
149 | + * |
|
150 | + */ |
|
151 | 151 | public function getMinLiveMarineData($filter = array()) |
152 | 152 | { |
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | - * Gets Minimal Live Spotter data since xx seconds |
|
181 | - * |
|
182 | - * @return Array the spotter information |
|
183 | - * |
|
184 | - */ |
|
180 | + * Gets Minimal Live Spotter data since xx seconds |
|
181 | + * |
|
182 | + * @return Array the spotter information |
|
183 | + * |
|
184 | + */ |
|
185 | 185 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * Gets number of latest data entry |
|
256 | - * |
|
257 | - * @return String number of entry |
|
258 | - * |
|
259 | - */ |
|
255 | + * Gets number of latest data entry |
|
256 | + * |
|
257 | + * @return String number of entry |
|
258 | + * |
|
259 | + */ |
|
260 | 260 | public function getLiveMarineCount($filter = array()) |
261 | 261 | { |
262 | 262 | global $globalDBdriver, $globalLiveInterval; |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * Gets all the spotter information based on the latest data entry and coord |
|
285 | - * |
|
286 | - * @return Array the spotter information |
|
287 | - * |
|
288 | - */ |
|
284 | + * Gets all the spotter information based on the latest data entry and coord |
|
285 | + * |
|
286 | + * @return Array the spotter information |
|
287 | + * |
|
288 | + */ |
|
289 | 289 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
290 | 290 | { |
291 | 291 | global $globalDBdriver, $globalLiveInterval; |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
312 | - * Gets all the spotter information based on the latest data entry and coord |
|
313 | - * |
|
314 | - * @return Array the spotter information |
|
315 | - * |
|
316 | - */ |
|
312 | + * Gets all the spotter information based on the latest data entry and coord |
|
313 | + * |
|
314 | + * @return Array the spotter information |
|
315 | + * |
|
316 | + */ |
|
317 | 317 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
318 | 318 | { |
319 | 319 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
385 | - * Gets all the spotter information based on a user's latitude and longitude |
|
386 | - * |
|
387 | - * @return Array the spotter information |
|
388 | - * |
|
389 | - */ |
|
385 | + * Gets all the spotter information based on a user's latitude and longitude |
|
386 | + * |
|
387 | + * @return Array the spotter information |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
391 | 391 | { |
392 | 392 | $Marine = new Marine($this->db); |
@@ -399,75 +399,75 @@ discard block |
||
399 | 399 | if ($lng != '') |
400 | 400 | { |
401 | 401 | if (!is_numeric($lng)) |
402 | - { |
|
403 | - return false; |
|
404 | - } |
|
405 | - } |
|
406 | - |
|
407 | - if ($radius != '') |
|
408 | - { |
|
409 | - if (!is_numeric($radius)) |
|
410 | - { |
|
411 | - return false; |
|
412 | - } |
|
413 | - } |
|
402 | + { |
|
403 | + return false; |
|
404 | + } |
|
405 | + } |
|
406 | + |
|
407 | + if ($radius != '') |
|
408 | + { |
|
409 | + if (!is_numeric($radius)) |
|
410 | + { |
|
411 | + return false; |
|
412 | + } |
|
413 | + } |
|
414 | 414 | $additional_query = ''; |
415 | 415 | if ($interval != '') |
416 | - { |
|
417 | - if (!is_string($interval)) |
|
418 | - { |
|
419 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
420 | - return false; |
|
421 | - } else { |
|
422 | - if ($interval == '1m') |
|
423 | - { |
|
424 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
425 | - } else if ($interval == '15m'){ |
|
426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
427 | - } |
|
428 | - } |
|
429 | - } else { |
|
430 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
431 | - } |
|
432 | - |
|
433 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
416 | + { |
|
417 | + if (!is_string($interval)) |
|
418 | + { |
|
419 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
420 | + return false; |
|
421 | + } else { |
|
422 | + if ($interval == '1m') |
|
423 | + { |
|
424 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
425 | + } else if ($interval == '15m'){ |
|
426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
427 | + } |
|
428 | + } |
|
429 | + } else { |
|
430 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
431 | + } |
|
432 | + |
|
433 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
434 | 434 | WHERE marine_live.latitude <> '' |
435 | 435 | AND marine_live.longitude <> '' |
436 | 436 | ".$additional_query." |
437 | 437 | HAVING distance < :radius |
438 | 438 | ORDER BY distance"; |
439 | 439 | |
440 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
440 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
441 | 441 | |
442 | - return $spotter_array; |
|
443 | - } |
|
442 | + return $spotter_array; |
|
443 | + } |
|
444 | 444 | |
445 | 445 | |
446 | - /** |
|
447 | - * Gets all the spotter information based on a particular callsign |
|
448 | - * |
|
449 | - * @return Array the spotter information |
|
450 | - * |
|
451 | - */ |
|
446 | + /** |
|
447 | + * Gets all the spotter information based on a particular callsign |
|
448 | + * |
|
449 | + * @return Array the spotter information |
|
450 | + * |
|
451 | + */ |
|
452 | 452 | public function getLastLiveMarineDataByIdent($ident) |
453 | 453 | { |
454 | 454 | $Marine = new Marine($this->db); |
455 | 455 | date_default_timezone_set('UTC'); |
456 | 456 | |
457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
458 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
458 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
459 | 459 | |
460 | 460 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
461 | 461 | |
462 | 462 | return $spotter_array; |
463 | 463 | } |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all the spotter information based on a particular callsign |
|
467 | - * |
|
468 | - * @return Array the spotter information |
|
469 | - * |
|
470 | - */ |
|
465 | + /** |
|
466 | + * Gets all the spotter information based on a particular callsign |
|
467 | + * |
|
468 | + * @return Array the spotter information |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function getDateLiveMarineDataByIdent($ident,$date) |
472 | 472 | { |
473 | 473 | $Marine = new Marine($this->db); |
@@ -480,11 +480,11 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
483 | - * Gets all the spotter information based on a particular MMSI |
|
484 | - * |
|
485 | - * @return Array the spotter information |
|
486 | - * |
|
487 | - */ |
|
483 | + * Gets all the spotter information based on a particular MMSI |
|
484 | + * |
|
485 | + * @return Array the spotter information |
|
486 | + * |
|
487 | + */ |
|
488 | 488 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
489 | 489 | { |
490 | 490 | $Marine = new Marine($this->db); |
@@ -496,51 +496,51 @@ discard block |
||
496 | 496 | return $spotter_array; |
497 | 497 | } |
498 | 498 | |
499 | - /** |
|
500 | - * Gets last spotter information based on a particular callsign |
|
501 | - * |
|
502 | - * @return Array the spotter information |
|
503 | - * |
|
504 | - */ |
|
499 | + /** |
|
500 | + * Gets last spotter information based on a particular callsign |
|
501 | + * |
|
502 | + * @return Array the spotter information |
|
503 | + * |
|
504 | + */ |
|
505 | 505 | public function getLastLiveMarineDataById($id) |
506 | 506 | { |
507 | 507 | $Marine = new Marine($this->db); |
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
511 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
511 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
512 | 512 | |
513 | 513 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
514 | 514 | |
515 | 515 | return $spotter_array; |
516 | 516 | } |
517 | 517 | |
518 | - /** |
|
519 | - * Gets last spotter information based on a particular callsign |
|
520 | - * |
|
521 | - * @return Array the spotter information |
|
522 | - * |
|
523 | - */ |
|
518 | + /** |
|
519 | + * Gets last spotter information based on a particular callsign |
|
520 | + * |
|
521 | + * @return Array the spotter information |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function getDateLiveMarineDataById($id,$date) |
525 | 525 | { |
526 | 526 | $Marine = new Marine($this->db); |
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | |
529 | 529 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
530 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
531 | - $date = date('c',$date); |
|
530 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
531 | + $date = date('c',$date); |
|
532 | 532 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
533 | 533 | |
534 | 534 | return $spotter_array; |
535 | 535 | } |
536 | 536 | |
537 | 537 | |
538 | - /** |
|
539 | - * Gets all the spotter information based on a particular id |
|
540 | - * |
|
541 | - * @return Array the spotter information |
|
542 | - * |
|
543 | - */ |
|
538 | + /** |
|
539 | + * Gets all the spotter information based on a particular id |
|
540 | + * |
|
541 | + * @return Array the spotter information |
|
542 | + * |
|
543 | + */ |
|
544 | 544 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
545 | 545 | { |
546 | 546 | global $globalDBdriver, $globalLiveInterval; |
@@ -568,18 +568,18 @@ discard block |
||
568 | 568 | return $spotter_array; |
569 | 569 | } |
570 | 570 | |
571 | - /** |
|
572 | - * Gets all the spotter information based on a particular ident |
|
573 | - * |
|
574 | - * @return Array the spotter information |
|
575 | - * |
|
576 | - */ |
|
571 | + /** |
|
572 | + * Gets all the spotter information based on a particular ident |
|
573 | + * |
|
574 | + * @return Array the spotter information |
|
575 | + * |
|
576 | + */ |
|
577 | 577 | public function getAllLiveMarineDataByIdent($ident) |
578 | 578 | { |
579 | 579 | date_default_timezone_set('UTC'); |
580 | 580 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
581 | 581 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
582 | - try { |
|
582 | + try { |
|
583 | 583 | |
584 | 584 | $sth = $this->db->prepare($query); |
585 | 585 | $sth->execute(array(':ident' => $ident)); |
@@ -593,23 +593,23 @@ discard block |
||
593 | 593 | |
594 | 594 | |
595 | 595 | /** |
596 | - * Deletes all info in the table |
|
597 | - * |
|
598 | - * @return String success or false |
|
599 | - * |
|
600 | - */ |
|
596 | + * Deletes all info in the table |
|
597 | + * |
|
598 | + * @return String success or false |
|
599 | + * |
|
600 | + */ |
|
601 | 601 | public function deleteLiveMarineData() |
602 | 602 | { |
603 | 603 | global $globalDBdriver; |
604 | 604 | if ($globalDBdriver == 'mysql') { |
605 | 605 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
606 | 606 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
607 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
607 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
608 | 608 | } else { |
609 | 609 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
610 | 610 | } |
611 | 611 | |
612 | - try { |
|
612 | + try { |
|
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
@@ -621,18 +621,18 @@ discard block |
||
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
624 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
625 | - * |
|
626 | - * @return String success or false |
|
627 | - * |
|
628 | - */ |
|
624 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
625 | + * |
|
626 | + * @return String success or false |
|
627 | + * |
|
628 | + */ |
|
629 | 629 | public function deleteLiveMarineDataNotUpdated() |
630 | 630 | { |
631 | 631 | global $globalDBdriver, $globalDebug; |
632 | 632 | if ($globalDBdriver == 'mysql') { |
633 | 633 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
634 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
635 | - try { |
|
634 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
635 | + try { |
|
636 | 636 | |
637 | 637 | $sth = $this->db->prepare($query); |
638 | 638 | $sth->execute(); |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | return "error"; |
641 | 641 | } |
642 | 642 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
643 | - $i = 0; |
|
644 | - $j =0; |
|
643 | + $i = 0; |
|
644 | + $j =0; |
|
645 | 645 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
646 | 646 | foreach($all as $row) |
647 | 647 | { |
@@ -649,20 +649,20 @@ discard block |
||
649 | 649 | $j++; |
650 | 650 | if ($j == 30) { |
651 | 651 | if ($globalDebug) echo "."; |
652 | - try { |
|
652 | + try { |
|
653 | 653 | |
654 | 654 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
655 | 655 | $sth->execute(); |
656 | 656 | } catch(PDOException $e) { |
657 | 657 | return "error"; |
658 | 658 | } |
659 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
660 | - $j = 0; |
|
659 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
660 | + $j = 0; |
|
661 | 661 | } |
662 | 662 | $query_delete .= "'".$row['fammarine_id']."',"; |
663 | 663 | } |
664 | 664 | if ($i > 0) { |
665 | - try { |
|
665 | + try { |
|
666 | 666 | |
667 | 667 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
668 | 668 | $sth->execute(); |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | return "success"; |
674 | 674 | } elseif ($globalDBdriver == 'pgsql') { |
675 | 675 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
676 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
677 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
678 | - try { |
|
676 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
677 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
678 | + try { |
|
679 | 679 | |
680 | 680 | $sth = $this->db->prepare($query); |
681 | 681 | $sth->execute(); |
@@ -719,17 +719,17 @@ discard block |
||
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | - * Deletes all info in the table for an ident |
|
723 | - * |
|
724 | - * @return String success or false |
|
725 | - * |
|
726 | - */ |
|
722 | + * Deletes all info in the table for an ident |
|
723 | + * |
|
724 | + * @return String success or false |
|
725 | + * |
|
726 | + */ |
|
727 | 727 | public function deleteLiveMarineDataByIdent($ident) |
728 | 728 | { |
729 | 729 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
730 | 730 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
731 | 731 | |
732 | - try { |
|
732 | + try { |
|
733 | 733 | |
734 | 734 | $sth = $this->db->prepare($query); |
735 | 735 | $sth->execute(array(':ident' => $ident)); |
@@ -741,17 +741,17 @@ discard block |
||
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
744 | - * Deletes all info in the table for an id |
|
745 | - * |
|
746 | - * @return String success or false |
|
747 | - * |
|
748 | - */ |
|
744 | + * Deletes all info in the table for an id |
|
745 | + * |
|
746 | + * @return String success or false |
|
747 | + * |
|
748 | + */ |
|
749 | 749 | public function deleteLiveMarineDataById($id) |
750 | 750 | { |
751 | 751 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
752 | 752 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
753 | 753 | |
754 | - try { |
|
754 | + try { |
|
755 | 755 | |
756 | 756 | $sth = $this->db->prepare($query); |
757 | 757 | $sth->execute(array(':id' => $id)); |
@@ -764,11 +764,11 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | /** |
767 | - * Gets the marine races |
|
768 | - * |
|
769 | - * @return Array all races |
|
770 | - * |
|
771 | - */ |
|
767 | + * Gets the marine races |
|
768 | + * |
|
769 | + * @return Array all races |
|
770 | + * |
|
771 | + */ |
|
772 | 772 | public function getAllRaces() |
773 | 773 | { |
774 | 774 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
781 | - * Gets the aircraft ident within the last hour |
|
782 | - * |
|
783 | - * @return String the ident |
|
784 | - * |
|
785 | - */ |
|
781 | + * Gets the aircraft ident within the last hour |
|
782 | + * |
|
783 | + * @return String the ident |
|
784 | + * |
|
785 | + */ |
|
786 | 786 | public function getIdentFromLastHour($ident) |
787 | 787 | { |
788 | 788 | global $globalDBdriver, $globalTimezone; |
@@ -808,14 +808,14 @@ discard block |
||
808 | 808 | $ident_result = $row['ident']; |
809 | 809 | } |
810 | 810 | return $ident_result; |
811 | - } |
|
811 | + } |
|
812 | 812 | |
813 | 813 | /** |
814 | - * Check recent aircraft |
|
815 | - * |
|
816 | - * @return String the ident |
|
817 | - * |
|
818 | - */ |
|
814 | + * Check recent aircraft |
|
815 | + * |
|
816 | + * @return String the ident |
|
817 | + * |
|
818 | + */ |
|
819 | 819 | public function checkIdentRecent($ident) |
820 | 820 | { |
821 | 821 | global $globalDBdriver, $globalTimezone; |
@@ -841,14 +841,14 @@ discard block |
||
841 | 841 | $ident_result = $row['fammarine_id']; |
842 | 842 | } |
843 | 843 | return $ident_result; |
844 | - } |
|
844 | + } |
|
845 | 845 | |
846 | 846 | /** |
847 | - * Check recent aircraft by id |
|
848 | - * |
|
849 | - * @return String the ident |
|
850 | - * |
|
851 | - */ |
|
847 | + * Check recent aircraft by id |
|
848 | + * |
|
849 | + * @return String the ident |
|
850 | + * |
|
851 | + */ |
|
852 | 852 | public function checkIdRecent($id) |
853 | 853 | { |
854 | 854 | global $globalDBdriver, $globalTimezone; |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | $ident_result = $row['fammarine_id']; |
875 | 875 | } |
876 | 876 | return $ident_result; |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | 879 | /** |
880 | - * Check recent aircraft by mmsi |
|
881 | - * |
|
882 | - * @return String the ident |
|
883 | - * |
|
884 | - */ |
|
880 | + * Check recent aircraft by mmsi |
|
881 | + * |
|
882 | + * @return String the ident |
|
883 | + * |
|
884 | + */ |
|
885 | 885 | public function checkMMSIRecent($mmsi) |
886 | 886 | { |
887 | 887 | global $globalDBdriver, $globalTimezone; |
@@ -907,19 +907,19 @@ discard block |
||
907 | 907 | $ident_result = $row['fammarine_id']; |
908 | 908 | } |
909 | 909 | return $ident_result; |
910 | - } |
|
910 | + } |
|
911 | 911 | |
912 | 912 | /** |
913 | - * Adds a new spotter data |
|
914 | - * |
|
915 | - * @param String $fammarine_id the ID from flightaware |
|
916 | - * @param String $ident the flight ident |
|
917 | - * @param String $aircraft_icao the aircraft type |
|
918 | - * @param String $departure_airport_icao the departure airport |
|
919 | - * @param String $arrival_airport_icao the arrival airport |
|
920 | - * @return String success or false |
|
921 | - * |
|
922 | - */ |
|
913 | + * Adds a new spotter data |
|
914 | + * |
|
915 | + * @param String $fammarine_id the ID from flightaware |
|
916 | + * @param String $ident the flight ident |
|
917 | + * @param String $aircraft_icao the aircraft type |
|
918 | + * @param String $departure_airport_icao the departure airport |
|
919 | + * @param String $arrival_airport_icao the arrival airport |
|
920 | + * @return String success or false |
|
921 | + * |
|
922 | + */ |
|
923 | 923 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
924 | 924 | { |
925 | 925 | global $globalURL, $globalArchive, $globalDebug; |
@@ -997,10 +997,10 @@ discard block |
||
997 | 997 | if ($typeid == '') $typeid = NULL; |
998 | 998 | if ($statusid == '') $statusid = NULL; |
999 | 999 | |
1000 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1001 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1002 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1003 | - $query = ''; |
|
1000 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1001 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1002 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1003 | + $query = ''; |
|
1004 | 1004 | if ($globalArchive) { |
1005 | 1005 | if ($globalDebug) echo '-- Delete previous data -- '; |
1006 | 1006 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
82 | 82 | } |
83 | 83 | } |
84 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
84 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
87 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
88 | 88 | } |
89 | 89 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
90 | 90 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
91 | 91 | if ($filter_query_where != '') { |
92 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
92 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
93 | 93 | } |
94 | 94 | $filter_query = $filter_query_join.$filter_query_where; |
95 | 95 | return $filter_query; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if ($limit != '') |
113 | 113 | { |
114 | 114 | $limit_array = explode(',', $limit); |
115 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
116 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
115 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
116 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
117 | 117 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
118 | 118 | { |
119 | 119 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 129 | } |
130 | 130 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
131 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
132 | 132 | |
133 | 133 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
134 | 134 | if ($globalDBdriver == 'mysql') { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
139 | 139 | } |
140 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
140 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
141 | 141 | |
142 | 142 | return $spotter_array; |
143 | 143 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
154 | 154 | date_default_timezone_set('UTC'); |
155 | 155 | |
156 | - $filter_query = $this->getFilter($filter,true,true); |
|
156 | + $filter_query = $this->getFilter($filter, true, true); |
|
157 | 157 | |
158 | 158 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
159 | 159 | if ($globalDBdriver == 'mysql') { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | try { |
168 | 168 | $sth = $this->db->prepare($query); |
169 | 169 | $sth->execute(); |
170 | - } catch(PDOException $e) { |
|
170 | + } catch (PDOException $e) { |
|
171 | 171 | echo $e->getMessage(); |
172 | 172 | die; |
173 | 173 | } |
@@ -182,19 +182,19 @@ discard block |
||
182 | 182 | * @return Array the spotter information |
183 | 183 | * |
184 | 184 | */ |
185 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
|
185 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false) |
|
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
188 | 188 | date_default_timezone_set('UTC'); |
189 | 189 | $usecoord = false; |
190 | 190 | if (is_array($coord) && !empty($coord)) { |
191 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
192 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
193 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
194 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
191 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
192 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
193 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
194 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
195 | 195 | $usecoord = true; |
196 | 196 | } |
197 | - $filter_query = $this->getFilter($filter,true,true); |
|
197 | + $filter_query = $this->getFilter($filter, true, true); |
|
198 | 198 | |
199 | 199 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
200 | 200 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | try { |
244 | 244 | $sth = $this->db->prepare($query); |
245 | 245 | $sth->execute(); |
246 | - } catch(PDOException $e) { |
|
246 | + } catch (PDOException $e) { |
|
247 | 247 | echo $e->getMessage(); |
248 | 248 | die; |
249 | 249 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public function getLiveMarineCount($filter = array()) |
261 | 261 | { |
262 | 262 | global $globalDBdriver, $globalLiveInterval; |
263 | - $filter_query = $this->getFilter($filter,true,true); |
|
263 | + $filter_query = $this->getFilter($filter, true, true); |
|
264 | 264 | |
265 | 265 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
266 | 266 | if ($globalDBdriver == 'mysql') { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | try { |
272 | 272 | $sth = $this->db->prepare($query); |
273 | 273 | $sth->execute(); |
274 | - } catch(PDOException $e) { |
|
274 | + } catch (PDOException $e) { |
|
275 | 275 | echo $e->getMessage(); |
276 | 276 | die; |
277 | 277 | } |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | $filter_query = $this->getFilter($filter); |
295 | 295 | |
296 | 296 | if (is_array($coord)) { |
297 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
298 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
299 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
300 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
297 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
298 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
299 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
300 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
301 | 301 | } else return array(); |
302 | 302 | if ($globalDBdriver == 'mysql') { |
303 | 303 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query; |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
320 | 320 | $Marine = new Marine($this->db); |
321 | 321 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
322 | - $filter_query = $this->getFilter($filter,true,true); |
|
322 | + $filter_query = $this->getFilter($filter, true, true); |
|
323 | 323 | |
324 | 324 | if (is_array($coord)) { |
325 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
326 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
327 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
328 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
325 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
326 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
327 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
328 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
329 | 329 | } else return array(); |
330 | 330 | /* |
331 | 331 | if ($globalDBdriver == 'mysql') { |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | */ |
341 | 341 | if ($globalDBdriver == 'mysql') { |
342 | 342 | if (isset($globalArchive) && $globalArchive === TRUE) { |
343 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
343 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
344 | 344 | FROM marine_live |
345 | 345 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
346 | 346 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
347 | 347 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY date DESC'; |
348 | 348 | } else { |
349 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
349 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
350 | 350 | FROM marine_live |
351 | 351 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
352 | 352 | FROM marine_live l |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | } |
359 | 359 | } else { |
360 | 360 | if (isset($globalArchive) && $globalArchive === TRUE) { |
361 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
361 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
362 | 362 | FROM marine_live |
363 | 363 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
364 | 364 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
365 | 365 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
366 | 366 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY date DESC"; |
367 | 367 | } else { |
368 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
368 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
369 | 369 | FROM marine_live |
370 | 370 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
371 | 371 | FROM marine_live l |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | if ($interval == '1m') |
423 | 423 | { |
424 | 424 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
425 | - } else if ($interval == '15m'){ |
|
425 | + } else if ($interval == '15m') { |
|
426 | 426 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
427 | 427 | } |
428 | 428 | } |
@@ -430,14 +430,14 @@ discard block |
||
430 | 430 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
431 | 431 | } |
432 | 432 | |
433 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
433 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
434 | 434 | WHERE marine_live.latitude <> '' |
435 | 435 | AND marine_live.longitude <> '' |
436 | 436 | ".$additional_query." |
437 | 437 | HAVING distance < :radius |
438 | 438 | ORDER BY distance"; |
439 | 439 | |
440 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
440 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
441 | 441 | |
442 | 442 | return $spotter_array; |
443 | 443 | } |
@@ -455,9 +455,9 @@ discard block |
||
455 | 455 | date_default_timezone_set('UTC'); |
456 | 456 | |
457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
458 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
458 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
459 | 459 | |
460 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
460 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
461 | 461 | |
462 | 462 | return $spotter_array; |
463 | 463 | } |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | * @return Array the spotter information |
469 | 469 | * |
470 | 470 | */ |
471 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
471 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
472 | 472 | { |
473 | 473 | $Marine = new Marine($this->db); |
474 | 474 | date_default_timezone_set('UTC'); |
475 | 475 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
476 | 476 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
477 | - $date = date('c',$date); |
|
478 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
477 | + $date = date('c', $date); |
|
478 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
479 | 479 | return $spotter_array; |
480 | 480 | } |
481 | 481 | |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | * @return Array the spotter information |
486 | 486 | * |
487 | 487 | */ |
488 | - public function getDateLiveMarineDataByMMSI($mmsi,$date) |
|
488 | + public function getDateLiveMarineDataByMMSI($mmsi, $date) |
|
489 | 489 | { |
490 | 490 | $Marine = new Marine($this->db); |
491 | 491 | date_default_timezone_set('UTC'); |
492 | 492 | $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
493 | 493 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
494 | - $date = date('c',$date); |
|
495 | - $spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date)); |
|
494 | + $date = date('c', $date); |
|
495 | + $spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date)); |
|
496 | 496 | return $spotter_array; |
497 | 497 | } |
498 | 498 | |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
511 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
511 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
512 | 512 | |
513 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
513 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
514 | 514 | |
515 | 515 | return $spotter_array; |
516 | 516 | } |
@@ -521,15 +521,15 @@ discard block |
||
521 | 521 | * @return Array the spotter information |
522 | 522 | * |
523 | 523 | */ |
524 | - public function getDateLiveMarineDataById($id,$date) |
|
524 | + public function getDateLiveMarineDataById($id, $date) |
|
525 | 525 | { |
526 | 526 | $Marine = new Marine($this->db); |
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | |
529 | 529 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
530 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
531 | - $date = date('c',$date); |
|
532 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
530 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
531 | + $date = date('c', $date); |
|
532 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
533 | 533 | |
534 | 534 | return $spotter_array; |
535 | 535 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @return Array the spotter information |
542 | 542 | * |
543 | 543 | */ |
544 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
544 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
545 | 545 | { |
546 | 546 | global $globalDBdriver, $globalLiveInterval; |
547 | 547 | date_default_timezone_set('UTC'); |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | try { |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':id' => $id)); |
563 | - } catch(PDOException $e) { |
|
563 | + } catch (PDOException $e) { |
|
564 | 564 | echo $e->getMessage(); |
565 | 565 | die; |
566 | 566 | } |
@@ -578,12 +578,12 @@ discard block |
||
578 | 578 | { |
579 | 579 | date_default_timezone_set('UTC'); |
580 | 580 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
581 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
581 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
582 | 582 | try { |
583 | 583 | |
584 | 584 | $sth = $this->db->prepare($query); |
585 | 585 | $sth->execute(array(':ident' => $ident)); |
586 | - } catch(PDOException $e) { |
|
586 | + } catch (PDOException $e) { |
|
587 | 587 | echo $e->getMessage(); |
588 | 588 | die; |
589 | 589 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
616 | - } catch(PDOException $e) { |
|
616 | + } catch (PDOException $e) { |
|
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | |
@@ -636,14 +636,14 @@ discard block |
||
636 | 636 | |
637 | 637 | $sth = $this->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error"; |
641 | 641 | } |
642 | 642 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
643 | 643 | $i = 0; |
644 | - $j =0; |
|
644 | + $j = 0; |
|
645 | 645 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
646 | - foreach($all as $row) |
|
646 | + foreach ($all as $row) |
|
647 | 647 | { |
648 | 648 | $i++; |
649 | 649 | $j++; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | if ($globalDebug) echo "."; |
652 | 652 | try { |
653 | 653 | |
654 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
654 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
655 | 655 | $sth->execute(); |
656 | - } catch(PDOException $e) { |
|
656 | + } catch (PDOException $e) { |
|
657 | 657 | return "error"; |
658 | 658 | } |
659 | 659 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | if ($i > 0) { |
665 | 665 | try { |
666 | 666 | |
667 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
667 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
668 | 668 | $sth->execute(); |
669 | - } catch(PDOException $e) { |
|
669 | + } catch (PDOException $e) { |
|
670 | 670 | return "error"; |
671 | 671 | } |
672 | 672 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | |
680 | 680 | $sth = $this->db->prepare($query); |
681 | 681 | $sth->execute(); |
682 | - } catch(PDOException $e) { |
|
682 | + } catch (PDOException $e) { |
|
683 | 683 | return "error"; |
684 | 684 | } |
685 | 685 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | public function deleteLiveMarineDataByIdent($ident) |
728 | 728 | { |
729 | 729 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
730 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
730 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
731 | 731 | |
732 | 732 | try { |
733 | 733 | |
734 | 734 | $sth = $this->db->prepare($query); |
735 | 735 | $sth->execute(array(':ident' => $ident)); |
736 | - } catch(PDOException $e) { |
|
736 | + } catch (PDOException $e) { |
|
737 | 737 | return "error"; |
738 | 738 | } |
739 | 739 | |
@@ -749,13 +749,13 @@ discard block |
||
749 | 749 | public function deleteLiveMarineDataById($id) |
750 | 750 | { |
751 | 751 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
752 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
752 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
753 | 753 | |
754 | 754 | try { |
755 | 755 | |
756 | 756 | $sth = $this->db->prepare($query); |
757 | 757 | $sth->execute(array(':id' => $id)); |
758 | - } catch(PDOException $e) { |
|
758 | + } catch (PDOException $e) { |
|
759 | 759 | return "error"; |
760 | 760 | } |
761 | 761 | |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | */ |
772 | 772 | public function getAllRaces() |
773 | 773 | { |
774 | - $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
774 | + $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
775 | 775 | $sth = $this->db->prepare($query); |
776 | 776 | $sth->execute(); |
777 | 777 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -787,13 +787,13 @@ discard block |
||
787 | 787 | { |
788 | 788 | global $globalDBdriver, $globalTimezone; |
789 | 789 | if ($globalDBdriver == 'mysql') { |
790 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
790 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
791 | 791 | WHERE marine_live.ident = :ident |
792 | 792 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
793 | 793 | AND marine_live.date < UTC_TIMESTAMP()'; |
794 | 794 | $query_data = array(':ident' => $ident); |
795 | 795 | } else { |
796 | - $query = "SELECT marine_live.ident FROM marine_live |
|
796 | + $query = "SELECT marine_live.ident FROM marine_live |
|
797 | 797 | WHERE marine_live.ident = :ident |
798 | 798 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
799 | 799 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | |
803 | 803 | $sth = $this->db->prepare($query); |
804 | 804 | $sth->execute($query_data); |
805 | - $ident_result=''; |
|
806 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
805 | + $ident_result = ''; |
|
806 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
807 | 807 | { |
808 | 808 | $ident_result = $row['ident']; |
809 | 809 | } |
@@ -820,13 +820,13 @@ discard block |
||
820 | 820 | { |
821 | 821 | global $globalDBdriver, $globalTimezone; |
822 | 822 | if ($globalDBdriver == 'mysql') { |
823 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
823 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
824 | 824 | WHERE marine_live.ident = :ident |
825 | 825 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
826 | 826 | // AND marine_live.date < UTC_TIMESTAMP()"; |
827 | 827 | $query_data = array(':ident' => $ident); |
828 | 828 | } else { |
829 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
829 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
830 | 830 | WHERE marine_live.ident = :ident |
831 | 831 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
832 | 832 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | |
836 | 836 | $sth = $this->db->prepare($query); |
837 | 837 | $sth->execute($query_data); |
838 | - $ident_result=''; |
|
839 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
838 | + $ident_result = ''; |
|
839 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
840 | 840 | { |
841 | 841 | $ident_result = $row['fammarine_id']; |
842 | 842 | } |
@@ -853,13 +853,13 @@ discard block |
||
853 | 853 | { |
854 | 854 | global $globalDBdriver, $globalTimezone; |
855 | 855 | if ($globalDBdriver == 'mysql') { |
856 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
856 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
857 | 857 | WHERE marine_live.fammarine_id = :id |
858 | 858 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
859 | 859 | // AND marine_live.date < UTC_TIMESTAMP()"; |
860 | 860 | $query_data = array(':id' => $id); |
861 | 861 | } else { |
862 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
862 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
863 | 863 | WHERE marine_live.fammarine_id = :id |
864 | 864 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
865 | 865 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | |
869 | 869 | $sth = $this->db->prepare($query); |
870 | 870 | $sth->execute($query_data); |
871 | - $ident_result=''; |
|
872 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
871 | + $ident_result = ''; |
|
872 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
873 | 873 | { |
874 | 874 | $ident_result = $row['fammarine_id']; |
875 | 875 | } |
@@ -886,13 +886,13 @@ discard block |
||
886 | 886 | { |
887 | 887 | global $globalDBdriver, $globalTimezone; |
888 | 888 | if ($globalDBdriver == 'mysql') { |
889 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
889 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
890 | 890 | WHERE marine_live.mmsi = :mmsi |
891 | 891 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
892 | 892 | // AND marine_live.date < UTC_TIMESTAMP()"; |
893 | 893 | $query_data = array(':mmsi' => $mmsi); |
894 | 894 | } else { |
895 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
895 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
896 | 896 | WHERE marine_live.mmsi = :mmsi |
897 | 897 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
898 | 898 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -901,8 +901,8 @@ discard block |
||
901 | 901 | |
902 | 902 | $sth = $this->db->prepare($query); |
903 | 903 | $sth->execute($query_data); |
904 | - $ident_result=''; |
|
905 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
904 | + $ident_result = ''; |
|
905 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
906 | 906 | { |
907 | 907 | $ident_result = $row['fammarine_id']; |
908 | 908 | } |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | * @return String success or false |
921 | 921 | * |
922 | 922 | */ |
923 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
|
923 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '') |
|
924 | 924 | { |
925 | 925 | global $globalURL, $globalArchive, $globalDebug; |
926 | 926 | $Common = new Common(); |
@@ -972,33 +972,33 @@ discard block |
||
972 | 972 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
973 | 973 | |
974 | 974 | |
975 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
976 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
977 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
978 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
979 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
980 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
981 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
982 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
983 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
984 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
985 | - $typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
986 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
987 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
988 | - $statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
990 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
991 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
992 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
993 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
994 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
995 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
996 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
975 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
976 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
977 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
978 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
979 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
980 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
981 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
982 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
983 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
984 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
985 | + $typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
986 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
988 | + $statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
990 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
991 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
992 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
993 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
994 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
995 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
996 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
997 | 997 | if ($typeid == '') $typeid = NULL; |
998 | 998 | if ($statusid == '') $statusid = NULL; |
999 | 999 | |
1000 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1001 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1000 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1001 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1002 | 1002 | if ($arrival_date == '') $arrival_date = NULL; |
1003 | 1003 | $query = ''; |
1004 | 1004 | if ($globalArchive) { |
@@ -1007,19 +1007,19 @@ discard block |
||
1007 | 1007 | } |
1008 | 1008 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) |
1009 | 1009 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name)'; |
1010 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name); |
|
1010 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name); |
|
1011 | 1011 | try { |
1012 | 1012 | $sth = $this->db->prepare($query); |
1013 | 1013 | $sth->execute($query_values); |
1014 | 1014 | $sth->closeCursor(); |
1015 | - } catch(PDOException $e) { |
|
1015 | + } catch (PDOException $e) { |
|
1016 | 1016 | return "error : ".$e->getMessage(); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1020 | 1020 | if ($globalDebug) echo '(Add to Marine archive : '; |
1021 | 1021 | $MarineArchive = new MarineArchive($this->db); |
1022 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name); |
|
1022 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name); |
|
1023 | 1023 | if ($globalDebug) echo $result.')'; |
1024 | 1024 | } |
1025 | 1025 | return "success"; |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | public function getOrderBy() |
1029 | 1029 | { |
1030 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
1030 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
1031 | 1031 | return $orderby; |
1032 | 1032 | } |
1033 | 1033 |