@@ -14,7 +14,7 @@ |
||
14 | 14 | $limit_start = 0; |
15 | 15 | $limit_end = 25; |
16 | 16 | $absolute_difference = 25; |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
19 | 19 | $limit_start = $limit_explode[0]; |
20 | 20 | $limit_end = $limit_explode[1]; |
@@ -6,7 +6,9 @@ |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Vessel Type"); |
7 | 7 | |
8 | 8 | $type = 'marine'; |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
11 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
12 | 14 |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | $temp += 1; |
124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
125 | 125 | $flat *= -1.0; |
126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
126 | + } else { |
|
127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
128 | + } |
|
127 | 129 | return $flat; // float |
128 | 130 | } |
129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
135 | 137 | $temp += 1; |
136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
137 | 139 | $flon *= -1.0; |
138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
140 | + } else { |
|
141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
142 | + } |
|
139 | 143 | return $flon; |
140 | 144 | } |
141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
158 | 162 | */ |
159 | 163 | private function asciidec_2_8bit($ascii) { |
160 | 164 | //only process in the following range: 48-87, 96-119 |
161 | - if ($ascii < 48) { } |
|
162 | - else { |
|
163 | - if($ascii>119) { } |
|
164 | - else { |
|
165 | + if ($ascii < 48) { } else { |
|
166 | + if($ascii>119) { } else { |
|
165 | 167 | if ($ascii>87 && $ascii<96) ; |
166 | 168 | else { |
167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
268 | + if ($ro->heading == 511) { |
|
269 | + $ro->heading = ''; |
|
270 | + } |
|
267 | 271 | $ro->cls = 2; // class B |
268 | 272 | } else if ($ro->id == 19) { |
269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
274 | 278 | $ro->cls = 2; // class B |
275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
280 | + if ($ro->heading == 511) { |
|
281 | + $ro->heading = ''; |
|
282 | + } |
|
277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
304 | 310 | $ro->cls = 2; // class B |
305 | 311 | } else if ($ro->id == 27) { |
306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
313 | + if ($ro->cog == 511) { |
|
314 | + $ro->cog = 0.0; |
|
315 | + } |
|
308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
317 | + if ($ro->sog == 63) { |
|
318 | + $ro->sog = 0.0; |
|
319 | + } |
|
310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
312 | 322 | $ro->cls = 1; // class A |
@@ -354,14 +364,20 @@ discard block |
||
354 | 364 | } |
355 | 365 | |
356 | 366 | public function getShipType($code) { |
357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
358 | - else return ''; |
|
367 | + if (isset($this->shiptype[$code])) { |
|
368 | + return $this->shiptype[$code]; |
|
369 | + } else { |
|
370 | + return ''; |
|
371 | + } |
|
359 | 372 | } |
360 | 373 | |
361 | 374 | public function getShipTypeID($type) { |
362 | 375 | $typeid = array_search($type,$this->shiptype); |
363 | - if ($typeid !== FALSE) return $typeid; |
|
364 | - else return ''; |
|
376 | + if ($typeid !== FALSE) { |
|
377 | + return $typeid; |
|
378 | + } else { |
|
379 | + return ''; |
|
380 | + } |
|
365 | 381 | } |
366 | 382 | |
367 | 383 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -398,11 +414,20 @@ discard block |
||
398 | 414 | // assume 1st ! is valid |
399 | 415 | // find * ensure that it is at correct position |
400 | 416 | $end = strrpos ( $rawdata , '*' ); |
401 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
417 | + if ($end === FALSE) { |
|
418 | + return -1; |
|
419 | + } |
|
420 | + // check for NULLS!!! |
|
402 | 421 | $cs = substr( $rawdata, $end + 1 ); |
403 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
422 | + if ( strlen($cs) != 2 ) { |
|
423 | + return -1; |
|
424 | + } |
|
425 | + // correct cs length |
|
404 | 426 | $dcs = (int)hexdec( $cs ); |
405 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
427 | + for ( $alias=1; $alias<$end; $alias++) { |
|
428 | + $chksum ^= ord( $rawdata[$alias] ); |
|
429 | + } |
|
430 | + // perform XOR for NMEA checksum |
|
406 | 431 | if ( $chksum == $dcs ) { // NMEA checksum pass |
407 | 432 | $pcs = explode(',', $rawdata); |
408 | 433 | // !AI??? identifier |
@@ -413,8 +438,14 @@ discard block |
||
413 | 438 | $num_seq = (int)$pcs[1]; // number of sequences |
414 | 439 | $seq = (int)$pcs[2]; // get sequence |
415 | 440 | // get msg sequence id |
416 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
417 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
441 | + if ($pcs[3] == '') { |
|
442 | + $msg_sid = -1; |
|
443 | + } |
|
444 | + // non-multipart message, set to -1 |
|
445 | + else { |
|
446 | + $msg_sid = (int)$pcs[3]; |
|
447 | + } |
|
448 | + // multipart message |
|
418 | 449 | $ais_ch = $pcs[4]; // get AIS channel |
419 | 450 | // message sequence checking |
420 | 451 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -477,10 +508,18 @@ discard block |
||
477 | 508 | //DEBUG echo "[$start $end $tst]\n"; |
478 | 509 | $result = $this->process_ais_raw( $tst, "" ); |
479 | 510 | $last_pos = $end + 1; |
480 | - } else break; |
|
511 | + } else { |
|
512 | + break; |
|
513 | + } |
|
514 | + } |
|
515 | + if ($last_pos > 0) { |
|
516 | + $cbuf = substr($cbuf, $last_pos); |
|
481 | 517 | } |
482 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
483 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
518 | + // move... |
|
519 | + if (strlen($cbuf) > 1024) { |
|
520 | + $cbuf = ""; |
|
521 | + } |
|
522 | + // prevent overflow simple mode... |
|
484 | 523 | return $result; |
485 | 524 | } |
486 | 525 | |
@@ -500,7 +539,9 @@ discard block |
||
500 | 539 | if ($lat<0.0) { |
501 | 540 | $lat = -$lat; |
502 | 541 | $neg=true; |
503 | - } else $neg=false; |
|
542 | + } else { |
|
543 | + $neg=false; |
|
544 | + } |
|
504 | 545 | $latd = 0x00000000; |
505 | 546 | $latd = intval ($lat * 600000.0); |
506 | 547 | if ($neg==true) { |
@@ -516,7 +557,9 @@ discard block |
||
516 | 557 | if ($lon<0.0) { |
517 | 558 | $lon = -$lon; |
518 | 559 | $neg=true; |
519 | - } else $neg=false; |
|
560 | + } else { |
|
561 | + $neg=false; |
|
562 | + } |
|
520 | 563 | $lond = 0x00000000; |
521 | 564 | $lond = intval ($lon * 600000.0); |
522 | 565 | if ($neg==true) { |
@@ -529,9 +572,14 @@ discard block |
||
529 | 572 | |
530 | 573 | private function char2bin($name, $max_len) { |
531 | 574 | $len = strlen($name); |
532 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
533 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
534 | - else $pad = ''; |
|
575 | + if ($len > $max_len) { |
|
576 | + $name = substr($name,0,$max_len); |
|
577 | + } |
|
578 | + if ($len < $max_len) { |
|
579 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
580 | + } else { |
|
581 | + $pad = ''; |
|
582 | + } |
|
535 | 583 | $rv = ''; |
536 | 584 | $ais_chars = array( |
537 | 585 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -544,9 +592,12 @@ discard block |
||
544 | 592 | ); |
545 | 593 | // " |
546 | 594 | $_a = str_split($name); |
547 | - if ($_a) foreach ($_a as $_1) { |
|
595 | + if ($_a) { |
|
596 | + foreach ($_a as $_1) { |
|
548 | 597 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
549 | - else $dec = 0; |
|
598 | + } else { |
|
599 | + $dec = 0; |
|
600 | + } |
|
550 | 601 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
551 | 602 | $rv .= $bin; |
552 | 603 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -558,7 +609,9 @@ discard block |
||
558 | 609 | $len_bit = strlen($_enc); |
559 | 610 | $rem6 = $len_bit % 6; |
560 | 611 | $pad6_len = 0; |
561 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
612 | + if ($rem6) { |
|
613 | + $pad6_len = 6 - $rem6; |
|
614 | + } |
|
562 | 615 | //echo $pad6_len.'<br>'; |
563 | 616 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
564 | 617 | $len_enc = strlen($_enc) / 6; |
@@ -567,8 +620,11 @@ discard block |
||
567 | 620 | for ($i=0; $i<$len_enc; $i++) { |
568 | 621 | $offset = $i * 6; |
569 | 622 | $dec = bindec(substr($_enc,$offset,6)); |
570 | - if ($dec < 40) $dec += 48; |
|
571 | - else $dec += 56; |
|
623 | + if ($dec < 40) { |
|
624 | + $dec += 48; |
|
625 | + } else { |
|
626 | + $dec += 56; |
|
627 | + } |
|
572 | 628 | //echo chr($dec)." $dec<br/>"; |
573 | 629 | $itu .= chr($dec); |
574 | 630 | } |
@@ -581,25 +637,41 @@ discard block |
||
581 | 637 | } |
582 | 638 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
583 | 639 | $lsb = $chksum & 0x0F; |
584 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
585 | - else $lsbc = '0'; |
|
640 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
641 | + $lsbc = $hex_arr[$lsb]; |
|
642 | + } else { |
|
643 | + $lsbc = '0'; |
|
644 | + } |
|
586 | 645 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
587 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
588 | - else $msbc = '0'; |
|
646 | + if ($msb >=0 && $msb <= 15 ) { |
|
647 | + $msbc = $hex_arr[$msb]; |
|
648 | + } else { |
|
649 | + $msbc = '0'; |
|
650 | + } |
|
589 | 651 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
590 | 652 | return $itu; |
591 | 653 | } |
592 | 654 | |
593 | 655 | public function parse($buffer) { |
594 | 656 | $data = $this->process_ais_buf($buffer); |
595 | - if (!is_object($data)) return array(); |
|
596 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
597 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
657 | + if (!is_object($data)) { |
|
658 | + return array(); |
|
659 | + } |
|
660 | + if ($data->lon != 0) { |
|
661 | + $result['longitude'] = $data->lon; |
|
662 | + } |
|
663 | + if ($data->lat != 0) { |
|
664 | + $result['latitude'] = $data->lat; |
|
665 | + } |
|
598 | 666 | $result['ident'] = trim($data->name); |
599 | 667 | $result['timestamp'] = $data->ts; |
600 | 668 | $result['mmsi'] = $data->mmsi; |
601 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
602 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
669 | + if ($data->sog != -1.0) { |
|
670 | + $result['speed'] = $data->sog; |
|
671 | + } |
|
672 | + if ($data->cog != 0) { |
|
673 | + $result['heading'] = $data->cog; |
|
674 | + } |
|
603 | 675 | /* |
604 | 676 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
605 | 677 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -609,15 +681,25 @@ discard block |
||
609 | 681 | |
610 | 682 | public function mmsitype($mmsi) { |
611 | 683 | if (strlen($mmsi) == 9) { |
612 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
613 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
614 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
615 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
616 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
617 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
618 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
619 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
620 | - else return 'Ship'; |
|
684 | + if (substr($mmsi,0,3) == '974') { |
|
685 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
686 | + } elseif (substr($mmsi,0,3) == '972') { |
|
687 | + return 'MOB (Man Overboard) device'; |
|
688 | + } elseif (substr($mmsi,0,3) == '970') { |
|
689 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
690 | + } elseif (substr($mmsi,0,3) == '111') { |
|
691 | + return 'SAR (Search and Rescue) aircraft'; |
|
692 | + } elseif (substr($mmsi,0,2) == '98') { |
|
693 | + return 'Auxiliary craft associated with a parent ship'; |
|
694 | + } elseif (substr($mmsi,0,2) == '99') { |
|
695 | + return 'Aids to Navigation'; |
|
696 | + } elseif (substr($mmsi,0,2) == '00') { |
|
697 | + return 'Coastal stations'; |
|
698 | + } elseif (substr($mmsi,0,1) == '0') { |
|
699 | + return 'Group of ships'; |
|
700 | + } else { |
|
701 | + return 'Ship'; |
|
702 | + } |
|
621 | 703 | } |
622 | 704 | |
623 | 705 | |
@@ -634,32 +716,61 @@ discard block |
||
634 | 716 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
635 | 717 | return array(); |
636 | 718 | } |
637 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
638 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
639 | 725 | $result['ident'] = trim(str_replace('@','',$data->name)); |
640 | 726 | $result['timestamp'] = $data->ts; |
641 | 727 | $result['mmsi'] = $data->mmsi; |
642 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
728 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
729 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
730 | + } |
|
643 | 731 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
644 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
645 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
646 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
647 | - if ($data->status != '') $result['status'] = $data->status; |
|
648 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
649 | - if ($data->type !== '') $result['type'] = $data->type; |
|
650 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
651 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
652 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
732 | + if ($data->sog != -1.0) { |
|
733 | + $result['speed'] = $data->sog; |
|
734 | + } |
|
735 | + if ($data->heading !== '') { |
|
736 | + $result['heading'] = $data->heading; |
|
737 | + } elseif ($data->cog != 0) { |
|
738 | + $result['heading'] = $data->cog; |
|
739 | + } |
|
740 | + if ($data->status != '') { |
|
741 | + $result['status'] = $data->status; |
|
742 | + } |
|
743 | + if ($data->statusid !== '') { |
|
744 | + $result['statusid'] = $data->statusid; |
|
745 | + } |
|
746 | + if ($data->type !== '') { |
|
747 | + $result['type'] = $data->type; |
|
748 | + } |
|
749 | + if ($data->typeid !== '') { |
|
750 | + $result['typeid'] = $data->typeid; |
|
751 | + } |
|
752 | + if ($data->imo !== '') { |
|
753 | + $result['imo'] = $data->imo; |
|
754 | + } |
|
755 | + if ($data->callsign !== '') { |
|
756 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
757 | + } |
|
653 | 758 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
654 | 759 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
655 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
760 | + if ($eta_ts != '') { |
|
761 | + $result['eta_ts'] = $eta_ts; |
|
762 | + } |
|
656 | 763 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
657 | 764 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
658 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
765 | + if ($eta_ts != '') { |
|
766 | + $result['eta_ts'] = $eta_ts; |
|
767 | + } |
|
659 | 768 | } |
660 | 769 | if ($data->destination != '') { |
661 | 770 | $dest = trim(str_replace('@','',$data->destination)); |
662 | - if ($dest != '') $result['destination'] = $dest; |
|
771 | + if ($dest != '') { |
|
772 | + $result['destination'] = $dest; |
|
773 | + } |
|
663 | 774 | } |
664 | 775 | $result['all'] = (array) $data; |
665 | 776 | /* |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -159,7 +185,9 @@ discard block |
||
159 | 185 | } |
160 | 186 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | 187 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
162 | - if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
188 | + if (!isset($line['type_id'])) { |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
190 | + } |
|
163 | 191 | } |
164 | 192 | if (isset($line['status']) && $line['status'] != '') { |
165 | 193 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
@@ -190,7 +218,9 @@ discard block |
||
190 | 218 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
191 | 219 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
192 | 220 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
193 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
223 | + } |
|
194 | 224 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
195 | 225 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
196 | 226 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -203,7 +233,9 @@ discard block |
||
203 | 233 | } |
204 | 234 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
205 | 235 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
206 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
238 | + } |
|
207 | 239 | if (!isset($line['id'])) { |
208 | 240 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
209 | 241 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -212,7 +244,9 @@ discard block |
||
212 | 244 | } |
213 | 245 | } |
214 | 246 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
215 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
247 | + if (strtotime($line['arrival_date']) > time()) { |
|
248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
249 | + } |
|
216 | 250 | } |
217 | 251 | |
218 | 252 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -225,35 +259,50 @@ discard block |
||
225 | 259 | $Marine = new Marine($this->db); |
226 | 260 | $fromsource = NULL; |
227 | 261 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
228 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
262 | + if ($globalDebug && $result != 'success') { |
|
263 | + echo '!!! ERROR : '.$result."\n"; |
|
264 | + } |
|
229 | 265 | $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
230 | 266 | $Marine->db = null; |
231 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
267 | + if ($globalDebugTimeElapsed) { |
|
268 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
269 | + } |
|
232 | 270 | } |
233 | 271 | } |
234 | 272 | } |
235 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
273 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
274 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
275 | + } |
|
236 | 276 | } |
237 | 277 | |
238 | 278 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
239 | 279 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
240 | 280 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
241 | 281 | } else { |
242 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
243 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
282 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
283 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
284 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
285 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
286 | + } |
|
244 | 287 | return ''; |
245 | 288 | } |
246 | 289 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
247 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
290 | + if ($globalDebug) { |
|
291 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
292 | + } |
|
248 | 293 | return ''; |
249 | 294 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
250 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
295 | + if ($globalDebug) { |
|
296 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
297 | + } |
|
251 | 298 | return ''; |
252 | 299 | } elseif (!isset($line['datetime'])) { |
253 | 300 | date_default_timezone_set('UTC'); |
254 | 301 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
255 | 302 | } else { |
256 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
303 | + if ($globalDebug) { |
|
304 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
305 | + } |
|
257 | 306 | return ''; |
258 | 307 | } |
259 | 308 | |
@@ -266,14 +315,21 @@ discard block |
||
266 | 315 | if ($distance > 1000 && $distance < 10000) { |
267 | 316 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
268 | 317 | $speed = $speed*3.6; |
269 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
270 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
318 | + if ($speed < 1000) { |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
320 | + } |
|
321 | + if ($globalDebug) { |
|
322 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
323 | + } |
|
271 | 324 | } |
272 | 325 | } |
273 | 326 | |
274 | 327 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
275 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
276 | - else unset($timediff); |
|
328 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
329 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
330 | + } else { |
|
331 | + unset($timediff); |
|
332 | + } |
|
277 | 333 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
278 | 334 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
279 | 335 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -281,22 +337,32 @@ discard block |
||
281 | 337 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
282 | 338 | $this->all_tracked[$id]['putinarchive'] = true; |
283 | 339 | |
284 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
340 | + if ($globalDebug) { |
|
341 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
342 | + } |
|
285 | 343 | $timeelapsed = microtime(true); |
286 | 344 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
287 | 345 | $Marine = new Marine($this->db); |
288 | 346 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
289 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
347 | + if (!empty($all_country)) { |
|
348 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
349 | + } |
|
290 | 350 | $Marine->db = null; |
291 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
351 | + if ($globalDebugTimeElapsed) { |
|
352 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
353 | + } |
|
292 | 354 | } |
293 | 355 | $this->tmd = 0; |
294 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
356 | + if ($globalDebug) { |
|
357 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
358 | + } |
|
295 | 359 | } |
296 | 360 | } |
297 | 361 | |
298 | 362 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
299 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
363 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
364 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
365 | + } |
|
300 | 366 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
301 | 367 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
302 | 368 | $dataFound = true; |
@@ -305,8 +371,12 @@ discard block |
||
305 | 371 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
306 | 372 | } |
307 | 373 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
308 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
309 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
374 | + if ($line['longitude'] > 180) { |
|
375 | + $line['longitude'] = $line['longitude'] - 360; |
|
376 | + } |
|
377 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
378 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
379 | + } |
|
310 | 380 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
311 | 381 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
312 | 382 | $dataFound = true; |
@@ -324,7 +394,9 @@ discard block |
||
324 | 394 | } |
325 | 395 | } |
326 | 396 | if (isset($line['last_update']) && $line['last_update'] != '') { |
327 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
397 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
398 | + $dataFound = true; |
|
399 | + } |
|
328 | 400 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
329 | 401 | } |
330 | 402 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -338,15 +410,21 @@ discard block |
||
338 | 410 | } |
339 | 411 | |
340 | 412 | if (isset($line['heading']) && $line['heading'] != '') { |
341 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
413 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
414 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
415 | + } |
|
342 | 416 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
343 | 417 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
344 | 418 | //$dataFound = true; |
345 | 419 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
346 | 420 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
347 | 421 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
348 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
349 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
422 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
423 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
424 | + } |
|
425 | + if ($globalDebug) { |
|
426 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
427 | + } |
|
350 | 428 | } |
351 | 429 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
352 | 430 | |
@@ -358,23 +436,38 @@ discard block |
||
358 | 436 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
359 | 437 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
360 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
361 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
439 | + if ($globalDebug) { |
|
440 | + echo "Check if vessel is already in DB..."; |
|
441 | + } |
|
362 | 442 | $timeelapsed = microtime(true); |
363 | 443 | $MarineLive = new MarineLive($this->db); |
364 | 444 | if (isset($line['id'])) { |
365 | 445 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
366 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
446 | + if ($globalDebugTimeElapsed) { |
|
447 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
448 | + } |
|
367 | 449 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
368 | 450 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
369 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
451 | + if ($globalDebugTimeElapsed) { |
|
452 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
453 | + } |
|
370 | 454 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
371 | 455 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | - } else $recent_ident = ''; |
|
456 | + if ($globalDebugTimeElapsed) { |
|
457 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + } |
|
459 | + } else { |
|
460 | + $recent_ident = ''; |
|
461 | + } |
|
374 | 462 | $MarineLive->db=null; |
375 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
376 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
377 | - } else $recent_ident = ''; |
|
463 | + if ($globalDebug && $recent_ident == '') { |
|
464 | + echo " Not in DB.\n"; |
|
465 | + } elseif ($globalDebug && $recent_ident != '') { |
|
466 | + echo " Already in DB.\n"; |
|
467 | + } |
|
468 | + } else { |
|
469 | + $recent_ident = ''; |
|
470 | + } |
|
378 | 471 | } else { |
379 | 472 | $recent_ident = ''; |
380 | 473 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -382,30 +475,44 @@ discard block |
||
382 | 475 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
383 | 476 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
384 | 477 | { |
385 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
478 | + if ($globalDebug) { |
|
479 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
480 | + } |
|
386 | 481 | //adds the spotter data for the archive |
387 | 482 | $highlight = ''; |
388 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
483 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
484 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
485 | + } |
|
389 | 486 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
390 | 487 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
391 | 488 | $timeelapsed = microtime(true); |
392 | 489 | $Marine = new Marine($this->db); |
393 | 490 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
394 | 491 | $Marine->db = null; |
395 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
396 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
492 | + if ($globalDebug && isset($result)) { |
|
493 | + echo $result."\n"; |
|
494 | + } |
|
495 | + if ($globalDebugTimeElapsed) { |
|
496 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
497 | + } |
|
397 | 498 | } |
398 | 499 | } |
399 | 500 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
400 | 501 | // Add source stat in DB |
401 | 502 | $Stats = new Stats($this->db); |
402 | 503 | if (!empty($this->stats)) { |
403 | - if ($globalDebug) echo 'Add source stats : '; |
|
504 | + if ($globalDebug) { |
|
505 | + echo 'Add source stats : '; |
|
506 | + } |
|
404 | 507 | foreach($this->stats as $date => $data) { |
405 | 508 | foreach($data as $source => $sourced) { |
406 | 509 | //print_r($sourced); |
407 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
408 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
510 | + if (isset($sourced['polar'])) { |
|
511 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
512 | + } |
|
513 | + if (isset($sourced['hist'])) { |
|
514 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
515 | + } |
|
409 | 516 | if (isset($sourced['msg'])) { |
410 | 517 | if (time() - $sourced['msg']['date'] > 10) { |
411 | 518 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -418,7 +525,9 @@ discard block |
||
418 | 525 | unset($this->stats[$date]); |
419 | 526 | } |
420 | 527 | } |
421 | - if ($globalDebug) echo 'Done'."\n"; |
|
528 | + if ($globalDebug) { |
|
529 | + echo 'Done'."\n"; |
|
530 | + } |
|
422 | 531 | } |
423 | 532 | $Stats->db = null; |
424 | 533 | } |
@@ -428,13 +537,17 @@ discard block |
||
428 | 537 | $this->all_tracked[$id]['addedMarine'] = 1; |
429 | 538 | //print_r($this->all_tracked[$id]); |
430 | 539 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
431 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
540 | + if ($globalDebug) { |
|
541 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
542 | + } |
|
432 | 543 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
433 | 544 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
434 | 545 | $MarineLive = new MarineLive($this->db); |
435 | 546 | $MarineLive->deleteLiveMarineData(); |
436 | 547 | $MarineLive->db=null; |
437 | - if ($globalDebug) echo " Done\n"; |
|
548 | + if ($globalDebug) { |
|
549 | + echo " Done\n"; |
|
550 | + } |
|
438 | 551 | } |
439 | 552 | $this->last_delete = time(); |
440 | 553 | } |
@@ -460,15 +573,21 @@ discard block |
||
460 | 573 | |
461 | 574 | if (!$ignoreImport) { |
462 | 575 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
463 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
576 | + if ($globalDebug) { |
|
577 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
578 | + } |
|
464 | 579 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
465 | 580 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
466 | 581 | $timeelapsed = microtime(true); |
467 | 582 | $MarineLive = new MarineLive($this->db); |
468 | 583 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
469 | 584 | $MarineLive->db = null; |
470 | - if ($globalDebug) echo $result."\n"; |
|
471 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
585 | + if ($globalDebug) { |
|
586 | + echo $result."\n"; |
|
587 | + } |
|
588 | + if ($globalDebugTimeElapsed) { |
|
589 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
590 | + } |
|
472 | 591 | } |
473 | 592 | } |
474 | 593 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -480,7 +599,9 @@ discard block |
||
480 | 599 | |
481 | 600 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
482 | 601 | $source = $this->all_tracked[$id]['source_name']; |
483 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
602 | + if ($source == '') { |
|
603 | + $source = $this->all_tracked[$id]['format_source']; |
|
604 | + } |
|
484 | 605 | if (!isset($this->source_location[$source])) { |
485 | 606 | $Location = new Source($this->db); |
486 | 607 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -501,7 +622,9 @@ discard block |
||
501 | 622 | $stats_heading = round($stats_heading/22.5); |
502 | 623 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
503 | 624 | $current_date = date('Y-m-d'); |
504 | - if ($stats_heading == 16) $stats_heading = 0; |
|
625 | + if ($stats_heading == 16) { |
|
626 | + $stats_heading = 0; |
|
627 | + } |
|
505 | 628 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
506 | 629 | for ($i=0;$i<=15;$i++) { |
507 | 630 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -519,7 +642,9 @@ discard block |
||
519 | 642 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
520 | 643 | end($this->stats[$current_date][$source]['hist']); |
521 | 644 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
522 | - } else $mini = 0; |
|
645 | + } else { |
|
646 | + $mini = 0; |
|
647 | + } |
|
523 | 648 | for ($i=$mini;$i<=$distance;$i+=10) { |
524 | 649 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
525 | 650 | } |
@@ -531,19 +656,27 @@ discard block |
||
531 | 656 | |
532 | 657 | |
533 | 658 | $this->all_tracked[$id]['lastupdate'] = time(); |
534 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
535 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
659 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
660 | + $send = true; |
|
661 | + } |
|
662 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
663 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
664 | + } |
|
536 | 665 | //$this->del(); |
537 | 666 | |
538 | 667 | |
539 | 668 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
540 | 669 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
541 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
670 | + if ($globalDebug) { |
|
671 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
672 | + } |
|
542 | 673 | $MarineLive = new MarineLive($this->db); |
543 | 674 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
544 | 675 | $MarineLive->db = null; |
545 | 676 | //MarineLive->deleteLiveMarineData(); |
546 | - if ($globalDebug) echo " Done\n"; |
|
677 | + if ($globalDebug) { |
|
678 | + echo " Done\n"; |
|
679 | + } |
|
547 | 680 | } |
548 | 681 | $this->last_delete_hourly = time(); |
549 | 682 | } |
@@ -552,7 +685,9 @@ discard block |
||
552 | 685 | //$ignoreImport = false; |
553 | 686 | } |
554 | 687 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
555 | - if ($send) return $this->all_tracked[$id]; |
|
688 | + if ($send) { |
|
689 | + return $this->all_tracked[$id]; |
|
690 | + } |
|
556 | 691 | } |
557 | 692 | } |
558 | 693 | } |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -72,8 +76,11 @@ discard block |
||
72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 77 | } |
74 | 78 | } |
75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
79 | + if ($filter_query_where == '' && $where) { |
|
80 | + $filter_query_where = ' WHERE'; |
|
81 | + } elseif ($filter_query_where != '' && $and) { |
|
82 | + $filter_query_where .= ' AND'; |
|
83 | + } |
|
77 | 84 | if ($filter_query_where != '') { |
78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
79 | 86 | } |
@@ -127,35 +134,63 @@ discard block |
||
127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
130 | - */} |
|
131 | - elseif (isset($row['marineid'])) { |
|
137 | + */} elseif (isset($row['marineid'])) { |
|
132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
133 | 139 | } else { |
134 | 140 | $temp_array['marine_id'] = ''; |
135 | 141 | } |
136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
140 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
141 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
142 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
143 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
144 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
145 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
146 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | + if (isset($row['fammarine_id'])) { |
|
143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
144 | + } |
|
145 | + if (isset($row['mmsi'])) { |
|
146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
147 | + } |
|
148 | + if (isset($row['type'])) { |
|
149 | + $temp_array['type'] = $row['type']; |
|
150 | + } |
|
151 | + if (isset($row['type_id'])) { |
|
152 | + $temp_array['type_id'] = $row['type_id']; |
|
153 | + } |
|
154 | + if (isset($row['status'])) { |
|
155 | + $temp_array['status'] = $row['status']; |
|
156 | + } |
|
157 | + if (isset($row['status_id'])) { |
|
158 | + $temp_array['status_id'] = $row['status_id']; |
|
159 | + } |
|
160 | + if (isset($row['ident'])) { |
|
161 | + $temp_array['ident'] = $row['ident']; |
|
162 | + } |
|
163 | + if (isset($row['arrival_port_name'])) { |
|
164 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
165 | + } |
|
166 | + if (isset($row['latitude'])) { |
|
167 | + $temp_array['latitude'] = $row['latitude']; |
|
168 | + } |
|
169 | + if (isset($row['longitude'])) { |
|
170 | + $temp_array['longitude'] = $row['longitude']; |
|
171 | + } |
|
172 | + if (isset($row['format_source'])) { |
|
173 | + $temp_array['format_source'] = $row['format_source']; |
|
174 | + } |
|
147 | 175 | if (isset($row['heading'])) { |
148 | 176 | $temp_array['heading'] = $row['heading']; |
149 | 177 | $heading_direction = $this->parseDirection($row['heading']); |
150 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
178 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
179 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
180 | + } |
|
181 | + } |
|
182 | + if (isset($row['ground_speed'])) { |
|
183 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
151 | 184 | } |
152 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
153 | 185 | |
154 | 186 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
155 | 187 | { |
156 | 188 | $Image = new Image($this->db); |
157 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
158 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
189 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
190 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
191 | + } else { |
|
192 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
193 | + } |
|
159 | 194 | unset($Image); |
160 | 195 | if (count($image_array) > 0) { |
161 | 196 | $temp_array['image'] = $image_array[0]['image']; |
@@ -207,13 +242,21 @@ discard block |
||
207 | 242 | } |
208 | 243 | |
209 | 244 | $fromsource = NULL; |
210 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
211 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
212 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
245 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
246 | + $temp_array['source_name'] = $row['source_name']; |
|
247 | + } |
|
248 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
249 | + $temp_array['over_country'] = $row['over_country']; |
|
250 | + } |
|
251 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
252 | + $temp_array['distance'] = $row['distance']; |
|
253 | + } |
|
213 | 254 | $temp_array['query_number_rows'] = $num_rows; |
214 | 255 | $spotter_array[] = $temp_array; |
215 | 256 | } |
216 | - if ($num_rows == 0) return array(); |
|
257 | + if ($num_rows == 0) { |
|
258 | + return array(); |
|
259 | + } |
|
217 | 260 | $spotter_array[0]['query_number_rows'] = $num_rows; |
218 | 261 | return $spotter_array; |
219 | 262 | } |
@@ -239,8 +282,12 @@ discard block |
||
239 | 282 | { |
240 | 283 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
241 | 284 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
242 | - } else $limit_query = ""; |
|
243 | - } else $limit_query = ""; |
|
285 | + } else { |
|
286 | + $limit_query = ""; |
|
287 | + } |
|
288 | + } else { |
|
289 | + $limit_query = ""; |
|
290 | + } |
|
244 | 291 | if ($sort != "") |
245 | 292 | { |
246 | 293 | $search_orderby_array = $this->getOrderBy(); |
@@ -264,7 +311,9 @@ discard block |
||
264 | 311 | global $global_query; |
265 | 312 | |
266 | 313 | date_default_timezone_set('UTC'); |
267 | - if ($id == '') return array(); |
|
314 | + if ($id == '') { |
|
315 | + return array(); |
|
316 | + } |
|
268 | 317 | $additional_query = "marine_output.fammarine_id = :id"; |
269 | 318 | $query_values = array(':id' => $id); |
270 | 319 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -460,8 +509,11 @@ discard block |
||
460 | 509 | $query .= " ORDER BY marine_output.source_name ASC"; |
461 | 510 | |
462 | 511 | $sth = $this->db->prepare($query); |
463 | - if (!empty($query_values)) $sth->execute($query_values); |
|
464 | - else $sth->execute(); |
|
512 | + if (!empty($query_values)) { |
|
513 | + $sth->execute($query_values); |
|
514 | + } else { |
|
515 | + $sth->execute(); |
|
516 | + } |
|
465 | 517 | |
466 | 518 | $source_array = array(); |
467 | 519 | $temp_array = array(); |
@@ -516,8 +568,11 @@ discard block |
||
516 | 568 | $sth = $this->db->prepare($query); |
517 | 569 | $sth->execute(array(':mmsi' => $mmsi)); |
518 | 570 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
519 | - if (isset($result[0])) return $result[0]; |
|
520 | - else return array(); |
|
571 | + if (isset($result[0])) { |
|
572 | + return $result[0]; |
|
573 | + } else { |
|
574 | + return array(); |
|
575 | + } |
|
521 | 576 | } |
522 | 577 | |
523 | 578 | /** |
@@ -558,7 +613,9 @@ discard block |
||
558 | 613 | date_default_timezone_set($globalTimezone); |
559 | 614 | $datetime = new DateTime(); |
560 | 615 | $offset = $datetime->format('P'); |
561 | - } else $offset = '+00:00'; |
|
616 | + } else { |
|
617 | + $offset = '+00:00'; |
|
618 | + } |
|
562 | 619 | |
563 | 620 | if ($globalDBdriver == 'mysql') { |
564 | 621 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -804,11 +861,21 @@ discard block |
||
804 | 861 | $latitude = 0; |
805 | 862 | $longitude = 0; |
806 | 863 | } |
807 | - if ($type_id == '') $type_id = NULL; |
|
808 | - if ($status_id == '') $status_id = NULL; |
|
809 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
810 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
811 | - if ($arrival_date == '') $arrival_date = NULL; |
|
864 | + if ($type_id == '') { |
|
865 | + $type_id = NULL; |
|
866 | + } |
|
867 | + if ($status_id == '') { |
|
868 | + $status_id = NULL; |
|
869 | + } |
|
870 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
871 | + $heading = 0; |
|
872 | + } |
|
873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
874 | + $groundspeed = 0; |
|
875 | + } |
|
876 | + if ($arrival_date == '') { |
|
877 | + $arrival_date = NULL; |
|
878 | + } |
|
812 | 879 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) |
813 | 880 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)"; |
814 | 881 | |
@@ -915,7 +982,9 @@ discard block |
||
915 | 982 | global $globalDBdriver, $globalArchive; |
916 | 983 | //$filter_query = $this->getFilter($filters,true,true); |
917 | 984 | $Connection= new Connection($this->db); |
918 | - if (!$Connection->tableExists('countries')) return array(); |
|
985 | + if (!$Connection->tableExists('countries')) { |
|
986 | + return array(); |
|
987 | + } |
|
919 | 988 | require_once('class.SpotterLive.php'); |
920 | 989 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
921 | 990 | $MarineLive = new MarineLive($this->db); |
@@ -959,7 +1028,9 @@ discard block |
||
959 | 1028 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
960 | 1029 | } |
961 | 1030 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
962 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1031 | + if ($limit) { |
|
1032 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1033 | + } |
|
963 | 1034 | |
964 | 1035 | $sth = $this->db->prepare($query); |
965 | 1036 | $sth->execute(); |
@@ -993,12 +1064,18 @@ discard block |
||
993 | 1064 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
994 | 1065 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
995 | 1066 | if ($olderthanmonths > 0) { |
996 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
997 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1067 | + if ($globalDBdriver == 'mysql') { |
|
1068 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1069 | + } else { |
|
1070 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1071 | + } |
|
998 | 1072 | } |
999 | 1073 | if ($sincedate != '') { |
1000 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1001 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1074 | + if ($globalDBdriver == 'mysql') { |
|
1075 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1076 | + } else { |
|
1077 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1078 | + } |
|
1002 | 1079 | } |
1003 | 1080 | $query_values = array(); |
1004 | 1081 | if ($year != '') { |
@@ -1029,7 +1106,9 @@ discard block |
||
1029 | 1106 | } |
1030 | 1107 | } |
1031 | 1108 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1032 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1109 | + if ($limit) { |
|
1110 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1111 | + } |
|
1033 | 1112 | |
1034 | 1113 | $sth = $this->db->prepare($query); |
1035 | 1114 | $sth->execute($query_values); |
@@ -1064,7 +1143,9 @@ discard block |
||
1064 | 1143 | date_default_timezone_set($globalTimezone); |
1065 | 1144 | $datetime = new DateTime(); |
1066 | 1145 | $offset = $datetime->format('P'); |
1067 | - } else $offset = '+00:00'; |
|
1146 | + } else { |
|
1147 | + $offset = '+00:00'; |
|
1148 | + } |
|
1068 | 1149 | |
1069 | 1150 | if ($globalDBdriver == 'mysql') { |
1070 | 1151 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1114,7 +1195,9 @@ discard block |
||
1114 | 1195 | date_default_timezone_set($globalTimezone); |
1115 | 1196 | $datetime = new DateTime(); |
1116 | 1197 | $offset = $datetime->format('P'); |
1117 | - } else $offset = '+00:00'; |
|
1198 | + } else { |
|
1199 | + $offset = '+00:00'; |
|
1200 | + } |
|
1118 | 1201 | $filter_query = $this->getFilter($filters,true,true); |
1119 | 1202 | if ($globalDBdriver == 'mysql') { |
1120 | 1203 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1160,7 +1243,9 @@ discard block |
||
1160 | 1243 | date_default_timezone_set($globalTimezone); |
1161 | 1244 | $datetime = new DateTime(); |
1162 | 1245 | $offset = $datetime->format('P'); |
1163 | - } else $offset = '+00:00'; |
|
1246 | + } else { |
|
1247 | + $offset = '+00:00'; |
|
1248 | + } |
|
1164 | 1249 | $filter_query = $this->getFilter($filters,true,true); |
1165 | 1250 | if ($globalDBdriver == 'mysql') { |
1166 | 1251 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1208,7 +1293,9 @@ discard block |
||
1208 | 1293 | date_default_timezone_set($globalTimezone); |
1209 | 1294 | $datetime = new DateTime(); |
1210 | 1295 | $offset = $datetime->format('P'); |
1211 | - } else $offset = '+00:00'; |
|
1296 | + } else { |
|
1297 | + $offset = '+00:00'; |
|
1298 | + } |
|
1212 | 1299 | |
1213 | 1300 | if ($globalDBdriver == 'mysql') { |
1214 | 1301 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1257,7 +1344,9 @@ discard block |
||
1257 | 1344 | date_default_timezone_set($globalTimezone); |
1258 | 1345 | $datetime = new DateTime(); |
1259 | 1346 | $offset = $datetime->format('P'); |
1260 | - } else $offset = '+00:00'; |
|
1347 | + } else { |
|
1348 | + $offset = '+00:00'; |
|
1349 | + } |
|
1261 | 1350 | $filter_query = $this->getFilter($filters,true,true); |
1262 | 1351 | if ($globalDBdriver == 'mysql') { |
1263 | 1352 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1306,7 +1395,9 @@ discard block |
||
1306 | 1395 | date_default_timezone_set($globalTimezone); |
1307 | 1396 | $datetime = new DateTime(); |
1308 | 1397 | $offset = $datetime->format('P'); |
1309 | - } else $offset = '+00:00'; |
|
1398 | + } else { |
|
1399 | + $offset = '+00:00'; |
|
1400 | + } |
|
1310 | 1401 | |
1311 | 1402 | $orderby_sql = ''; |
1312 | 1403 | if ($orderby == "hour") |
@@ -1375,7 +1466,9 @@ discard block |
||
1375 | 1466 | date_default_timezone_set($globalTimezone); |
1376 | 1467 | $datetime = new DateTime($date); |
1377 | 1468 | $offset = $datetime->format('P'); |
1378 | - } else $offset = '+00:00'; |
|
1469 | + } else { |
|
1470 | + $offset = '+00:00'; |
|
1471 | + } |
|
1379 | 1472 | |
1380 | 1473 | if ($globalDBdriver == 'mysql') { |
1381 | 1474 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1423,7 +1516,9 @@ discard block |
||
1423 | 1516 | date_default_timezone_set($globalTimezone); |
1424 | 1517 | $datetime = new DateTime(); |
1425 | 1518 | $offset = $datetime->format('P'); |
1426 | - } else $offset = '+00:00'; |
|
1519 | + } else { |
|
1520 | + $offset = '+00:00'; |
|
1521 | + } |
|
1427 | 1522 | |
1428 | 1523 | if ($globalDBdriver == 'mysql') { |
1429 | 1524 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1488,8 +1583,11 @@ discard block |
||
1488 | 1583 | $query_values = array_merge($query_values,array(':month' => $month)); |
1489 | 1584 | } |
1490 | 1585 | } |
1491 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1492 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1586 | + if (empty($query_values)) { |
|
1587 | + $queryi .= $this->getFilter($filters); |
|
1588 | + } else { |
|
1589 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1590 | + } |
|
1493 | 1591 | |
1494 | 1592 | $sth = $this->db->prepare($queryi); |
1495 | 1593 | $sth->execute($query_values); |
@@ -1526,8 +1624,11 @@ discard block |
||
1526 | 1624 | $query_values = array_merge($query_values,array(':month' => $month)); |
1527 | 1625 | } |
1528 | 1626 | } |
1529 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1530 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1627 | + if (empty($query_values)) { |
|
1628 | + $queryi .= $this->getFilter($filters); |
|
1629 | + } else { |
|
1630 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1631 | + } |
|
1531 | 1632 | |
1532 | 1633 | $sth = $this->db->prepare($queryi); |
1533 | 1634 | $sth->execute($query_values); |
@@ -1549,7 +1650,9 @@ discard block |
||
1549 | 1650 | date_default_timezone_set($globalTimezone); |
1550 | 1651 | $datetime = new DateTime(); |
1551 | 1652 | $offset = $datetime->format('P'); |
1552 | - } else $offset = '+00:00'; |
|
1653 | + } else { |
|
1654 | + $offset = '+00:00'; |
|
1655 | + } |
|
1553 | 1656 | |
1554 | 1657 | if ($globalDBdriver == 'mysql') { |
1555 | 1658 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1653,7 +1756,9 @@ discard block |
||
1653 | 1756 | */ |
1654 | 1757 | public function parseDirection($direction = 0) |
1655 | 1758 | { |
1656 | - if ($direction == '') $direction = 0; |
|
1759 | + if ($direction == '') { |
|
1760 | + $direction = 0; |
|
1761 | + } |
|
1657 | 1762 | $direction_array = array(); |
1658 | 1763 | $temp_array = array(); |
1659 | 1764 | |
@@ -1742,7 +1847,9 @@ discard block |
||
1742 | 1847 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1743 | 1848 | |
1744 | 1849 | $Connection = new Connection($this->db); |
1745 | - if (!$Connection->tableExists('countries')) return ''; |
|
1850 | + if (!$Connection->tableExists('countries')) { |
|
1851 | + return ''; |
|
1852 | + } |
|
1746 | 1853 | |
1747 | 1854 | try { |
1748 | 1855 | /* |
@@ -1762,9 +1869,13 @@ discard block |
||
1762 | 1869 | $sth->closeCursor(); |
1763 | 1870 | if (count($row) > 0) { |
1764 | 1871 | return $row; |
1765 | - } else return ''; |
|
1872 | + } else { |
|
1873 | + return ''; |
|
1874 | + } |
|
1766 | 1875 | } catch (PDOException $e) { |
1767 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1876 | + if (isset($globalDebug) && $globalDebug) { |
|
1877 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1878 | + } |
|
1768 | 1879 | return ''; |
1769 | 1880 | } |
1770 | 1881 | |
@@ -1782,7 +1893,9 @@ discard block |
||
1782 | 1893 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1783 | 1894 | |
1784 | 1895 | $Connection = new Connection($this->db); |
1785 | - if (!$Connection->tableExists('countries')) return ''; |
|
1896 | + if (!$Connection->tableExists('countries')) { |
|
1897 | + return ''; |
|
1898 | + } |
|
1786 | 1899 | |
1787 | 1900 | try { |
1788 | 1901 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1794,9 +1907,13 @@ discard block |
||
1794 | 1907 | $sth->closeCursor(); |
1795 | 1908 | if (count($row) > 0) { |
1796 | 1909 | return $row; |
1797 | - } else return ''; |
|
1910 | + } else { |
|
1911 | + return ''; |
|
1912 | + } |
|
1798 | 1913 | } catch (PDOException $e) { |
1799 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1914 | + if (isset($globalDebug) && $globalDebug) { |
|
1915 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1916 | + } |
|
1800 | 1917 | return ''; |
1801 | 1918 | } |
1802 | 1919 | |
@@ -1814,7 +1931,9 @@ discard block |
||
1814 | 1931 | { |
1815 | 1932 | global $globalBitlyAccessToken; |
1816 | 1933 | |
1817 | - if ($globalBitlyAccessToken == '') return $url; |
|
1934 | + if ($globalBitlyAccessToken == '') { |
|
1935 | + return $url; |
|
1936 | + } |
|
1818 | 1937 | |
1819 | 1938 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1820 | 1939 | |
@@ -1890,7 +2009,9 @@ discard block |
||
1890 | 2009 | } |
1891 | 2010 | } |
1892 | 2011 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
1893 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2012 | + if ($limit) { |
|
2013 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2014 | + } |
|
1894 | 2015 | $sth = $this->db->prepare($query); |
1895 | 2016 | $sth->execute($query_values); |
1896 | 2017 | $marine_array = array(); |
@@ -1928,9 +2049,15 @@ discard block |
||
1928 | 2049 | foreach ($q_array as $q_item){ |
1929 | 2050 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1930 | 2051 | $additional_query .= " AND ("; |
1931 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1932 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1933 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2052 | + if (is_int($q_item)) { |
|
2053 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2054 | + } |
|
2055 | + if (is_int($q_item)) { |
|
2056 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2057 | + } |
|
2058 | + if (is_int($q_item)) { |
|
2059 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2060 | + } |
|
1934 | 2061 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1935 | 2062 | $additional_query .= ")"; |
1936 | 2063 | } |
@@ -1978,7 +2105,9 @@ discard block |
||
1978 | 2105 | date_default_timezone_set($globalTimezone); |
1979 | 2106 | $datetime = new DateTime(); |
1980 | 2107 | $offset = $datetime->format('P'); |
1981 | - } else $offset = '+00:00'; |
|
2108 | + } else { |
|
2109 | + $offset = '+00:00'; |
|
2110 | + } |
|
1982 | 2111 | if ($date_array[1] != "") |
1983 | 2112 | { |
1984 | 2113 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2005,8 +2134,12 @@ discard block |
||
2005 | 2134 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2006 | 2135 | { |
2007 | 2136 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2008 | - } else $limit_query = ""; |
|
2009 | - } else $limit_query = ""; |
|
2137 | + } else { |
|
2138 | + $limit_query = ""; |
|
2139 | + } |
|
2140 | + } else { |
|
2141 | + $limit_query = ""; |
|
2142 | + } |
|
2010 | 2143 | if ($sort != "") |
2011 | 2144 | { |
2012 | 2145 | $search_orderby_array = $this->getOrderBy(); |