@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | public function buildcloudlayer($metar) { |
5 | 5 | //print_r($metar); |
6 | 6 | $result = array(); |
7 | - foreach($metar['cloud'] as $key => $data) { |
|
7 | + foreach ($metar['cloud'] as $key => $data) { |
|
8 | 8 | $alt_m = $metar['cloud'][$key]['level']; |
9 | 9 | $alt_ft = $alt_m*3.28084; |
10 | 10 | $pressure = $metar['QNH']; |
11 | - $cumulus_base = 122.0 * ($metar['temperature'] - $metar['dew']); |
|
12 | - $stratus_base = 100.0 * (100.0 * $metar['rh'])*0.3048; |
|
11 | + $cumulus_base = 122.0*($metar['temperature'] - $metar['dew']); |
|
12 | + $stratus_base = 100.0*(100.0*$metar['rh'])*0.3048; |
|
13 | 13 | $coverage_norm = 0.0; |
14 | 14 | if ($metar['cloud'][$key]['type'] == 'Few') { |
15 | 15 | $coverage_norm = 2.0/8.0; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | $layer_type = 'ns'; |
32 | 32 | } |
33 | 33 | } else { |
34 | - if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) { |
|
34 | + if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) { |
|
35 | 35 | $layer_type = 'cu'; |
36 | - } elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) { |
|
36 | + } elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) { |
|
37 | 37 | $layer_type = 'st'; |
38 | 38 | } else { |
39 | 39 | if ($alt_ft < 2000) { |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | //echo 'coverage norm : '.$coverage_norm.' - layer_type: '.$layer_type."\n"; |
49 | - $result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $metar['rh']); |
|
49 | + $result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $metar['rh']); |
|
50 | 50 | } |
51 | 51 | if (count($result) < 2 && $metar['rh'] > 60) { |
52 | - $result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $metar['rh']); |
|
52 | + $result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $metar['rh']); |
|
53 | 53 | } |
54 | 54 | return $result; |
55 | 55 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | // http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t05z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&lev_surface=on&var_TMP=on&var_UGRD=on&var_VGRD=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=/gfs.2017111717 |
70 | 70 | $resolution = '0.5'; |
71 | - $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00':'0p50').'.pl'; |
|
72 | - $get = array('file' => 'gfs.t'.sprintf('%02d',(6*floor(date('G')/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
71 | + $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00' : '0p50').'.pl'; |
|
72 | + $get = array('file' => 'gfs.t'.sprintf('%02d', (6*floor(date('G')/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
73 | 73 | 'lev_10_m_above_ground' => 'on', |
74 | 74 | 'lev_surface' => 'on', |
75 | 75 | 'var_TMP' => 'on', |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | 'rightlon' => 360, |
80 | 80 | 'toplat' => 90, |
81 | 81 | 'bottomlat' => -90, |
82 | - 'dir' => '/gfs.'.date('Ymd').sprintf('%02d',(6*floor(date('G')/6))) |
|
82 | + 'dir' => '/gfs.'.date('Ymd').sprintf('%02d', (6*floor(date('G')/6))) |
|
83 | 83 | ); |
84 | 84 | $url = $baseurl.'?'.http_build_query($get); |
85 | 85 | echo $url; |
86 | 86 | $Common = new Common(); |
87 | - $Common->download($url,$windpathsrc); |
|
87 | + $Common->download($url, $windpathsrc); |
|
88 | 88 | system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc); |
89 | 89 | } |
90 | 90 | } |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | - * Get SQL query part for filter used |
|
18 | - * @param Array $filter the filter |
|
19 | - * @return Array the SQL part |
|
20 | - */ |
|
17 | + * Get SQL query part for filter used |
|
18 | + * @param Array $filter the filter |
|
19 | + * @return Array the SQL part |
|
20 | + */ |
|
21 | 21 | |
22 | 22 | public function getFilter($filter = array(),$where = false,$and = false) { |
23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * Executes the SQL statements to get the tracker information |
|
88 | - * |
|
89 | - * @param String $query the SQL query |
|
90 | - * @param Array $params parameter of the query |
|
91 | - * @param String $limitQuery the limit query |
|
92 | - * @return Array the tracker information |
|
93 | - * |
|
94 | - */ |
|
87 | + * Executes the SQL statements to get the tracker information |
|
88 | + * |
|
89 | + * @param String $query the SQL query |
|
90 | + * @param Array $params parameter of the query |
|
91 | + * @param String $limitQuery the limit query |
|
92 | + * @return Array the tracker information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
96 | 96 | { |
97 | 97 | date_default_timezone_set('UTC'); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | /** |
207 | - * Gets all the tracker information based on the latest data entry |
|
208 | - * |
|
209 | - * @return Array the tracker information |
|
210 | - * |
|
211 | - */ |
|
207 | + * Gets all the tracker information based on the latest data entry |
|
208 | + * |
|
209 | + * @return Array the tracker information |
|
210 | + * |
|
211 | + */ |
|
212 | 212 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array()) |
213 | 213 | { |
214 | 214 | global $global_tracker_query; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Gets all the tracker information based on the callsign |
|
270 | - * |
|
271 | - * @return Array the tracker information |
|
272 | - * |
|
273 | - */ |
|
269 | + * Gets all the tracker information based on the callsign |
|
270 | + * |
|
271 | + * @return Array the tracker information |
|
272 | + * |
|
273 | + */ |
|
274 | 274 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
275 | 275 | { |
276 | 276 | global $global_tracker_query; |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | |
383 | 383 | /** |
384 | - * Gets all source name |
|
385 | - * |
|
386 | - * @param String type format of source |
|
387 | - * @return Array list of source name |
|
388 | - * |
|
389 | - */ |
|
384 | + * Gets all source name |
|
385 | + * |
|
386 | + * @param String type format of source |
|
387 | + * @return Array list of source name |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getAllSourceName($type = '',$filters = array()) |
391 | 391 | { |
392 | 392 | $filter_query = $this->getFilter($filters,true,true); |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | |
417 | 417 | |
418 | 418 | /** |
419 | - * Gets a list of all idents/callsigns |
|
420 | - * |
|
421 | - * @return Array list of ident/callsign names |
|
422 | - * |
|
423 | - */ |
|
419 | + * Gets a list of all idents/callsigns |
|
420 | + * |
|
421 | + * @return Array list of ident/callsign names |
|
422 | + * |
|
423 | + */ |
|
424 | 424 | public function getAllIdents($filters = array()) |
425 | 425 | { |
426 | 426 | $filter_query = $this->getFilter($filters,true,true); |
@@ -488,18 +488,18 @@ discard block |
||
488 | 488 | |
489 | 489 | |
490 | 490 | /** |
491 | - * Update ident tracker data |
|
492 | - * |
|
493 | - * @param String $flightaware_id the ID from flightaware |
|
494 | - * @param String $ident the flight ident |
|
495 | - * @return String success or false |
|
496 | - * |
|
497 | - */ |
|
491 | + * Update ident tracker data |
|
492 | + * |
|
493 | + * @param String $flightaware_id the ID from flightaware |
|
494 | + * @param String $ident the flight ident |
|
495 | + * @return String success or false |
|
496 | + * |
|
497 | + */ |
|
498 | 498 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
499 | 499 | { |
500 | 500 | |
501 | 501 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
502 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
502 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
503 | 503 | |
504 | 504 | try { |
505 | 505 | $sth = $this->db->prepare($query); |
@@ -512,18 +512,18 @@ discard block |
||
512 | 512 | |
513 | 513 | } |
514 | 514 | /** |
515 | - * Update latest tracker data |
|
516 | - * |
|
517 | - * @param String $flightaware_id the ID from flightaware |
|
518 | - * @param String $ident the flight ident |
|
519 | - * @param String $arrival_airport_icao the arrival airport |
|
520 | - * @return String success or false |
|
521 | - * |
|
522 | - */ |
|
515 | + * Update latest tracker data |
|
516 | + * |
|
517 | + * @param String $flightaware_id the ID from flightaware |
|
518 | + * @param String $ident the flight ident |
|
519 | + * @param String $arrival_airport_icao the arrival airport |
|
520 | + * @return String success or false |
|
521 | + * |
|
522 | + */ |
|
523 | 523 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
524 | 524 | { |
525 | 525 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
526 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
526 | + $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
527 | 527 | |
528 | 528 | try { |
529 | 529 | $sth = $this->db->prepare($query); |
@@ -537,32 +537,32 @@ discard block |
||
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
540 | - * Adds a new tracker data |
|
541 | - * |
|
542 | - * @param String $flightaware_id the ID from flightaware |
|
543 | - * @param String $ident the flight ident |
|
544 | - * @param String $aircraft_icao the aircraft type |
|
545 | - * @param String $departure_airport_icao the departure airport |
|
546 | - * @param String $arrival_airport_icao the arrival airport |
|
547 | - * @param String $latitude latitude of flight |
|
548 | - * @param String $longitude latitude of flight |
|
549 | - * @param String $waypoints waypoints of flight |
|
550 | - * @param String $altitude altitude of flight |
|
551 | - * @param String $heading heading of flight |
|
552 | - * @param String $groundspeed speed of flight |
|
553 | - * @param String $date date of flight |
|
554 | - * @param String $departure_airport_time departure time of flight |
|
555 | - * @param String $arrival_airport_time arrival time of flight |
|
556 | - * @param String $squawk squawk code of flight |
|
557 | - * @param String $route_stop route stop of flight |
|
558 | - * @param String $highlight highlight or not |
|
559 | - * @param String $ModeS ModesS code of flight |
|
560 | - * @param String $registration registration code of flight |
|
561 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
562 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
563 | - * @param String $verticalrate vertival rate of flight |
|
564 | - * @return String success or false |
|
565 | - */ |
|
540 | + * Adds a new tracker data |
|
541 | + * |
|
542 | + * @param String $flightaware_id the ID from flightaware |
|
543 | + * @param String $ident the flight ident |
|
544 | + * @param String $aircraft_icao the aircraft type |
|
545 | + * @param String $departure_airport_icao the departure airport |
|
546 | + * @param String $arrival_airport_icao the arrival airport |
|
547 | + * @param String $latitude latitude of flight |
|
548 | + * @param String $longitude latitude of flight |
|
549 | + * @param String $waypoints waypoints of flight |
|
550 | + * @param String $altitude altitude of flight |
|
551 | + * @param String $heading heading of flight |
|
552 | + * @param String $groundspeed speed of flight |
|
553 | + * @param String $date date of flight |
|
554 | + * @param String $departure_airport_time departure time of flight |
|
555 | + * @param String $arrival_airport_time arrival time of flight |
|
556 | + * @param String $squawk squawk code of flight |
|
557 | + * @param String $route_stop route stop of flight |
|
558 | + * @param String $highlight highlight or not |
|
559 | + * @param String $ModeS ModesS code of flight |
|
560 | + * @param String $registration registration code of flight |
|
561 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
562 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
563 | + * @param String $verticalrate vertival rate of flight |
|
564 | + * @return String success or false |
|
565 | + */ |
|
566 | 566 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
567 | 567 | { |
568 | 568 | global $globalURL; |
@@ -647,16 +647,16 @@ discard block |
||
647 | 647 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
648 | 648 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
649 | 649 | |
650 | - if ($latitude == '' && $longitude == '') { |
|
651 | - $latitude = 0; |
|
652 | - $longitude = 0; |
|
653 | - } |
|
654 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
655 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
656 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
650 | + if ($latitude == '' && $longitude == '') { |
|
651 | + $latitude = 0; |
|
652 | + $longitude = 0; |
|
653 | + } |
|
654 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
655 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
656 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
657 | 657 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
658 | 658 | |
659 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
659 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
660 | 660 | |
661 | 661 | try { |
662 | 662 | |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | $sth->execute($query_values); |
665 | 665 | $this->db = null; |
666 | 666 | } catch (PDOException $e) { |
667 | - return "error : ".$e->getMessage(); |
|
667 | + return "error : ".$e->getMessage(); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | return "success"; |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | |
674 | 674 | |
675 | 675 | /** |
676 | - * Gets the aircraft ident within the last hour |
|
677 | - * |
|
678 | - * @return String the ident |
|
679 | - * |
|
680 | - */ |
|
676 | + * Gets the aircraft ident within the last hour |
|
677 | + * |
|
678 | + * @return String the ident |
|
679 | + * |
|
680 | + */ |
|
681 | 681 | public function getIdentFromLastHour($ident) |
682 | 682 | { |
683 | 683 | global $globalDBdriver, $globalTimezone; |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
694 | 694 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
695 | 695 | $query_data = array(':ident' => $ident); |
696 | - } |
|
696 | + } |
|
697 | 697 | |
698 | 698 | $sth = $this->db->prepare($query); |
699 | 699 | $sth->execute($query_data); |
700 | - $ident_result=''; |
|
700 | + $ident_result=''; |
|
701 | 701 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
702 | 702 | { |
703 | 703 | $ident_result = $row['ident']; |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | |
709 | 709 | |
710 | 710 | /** |
711 | - * Gets the aircraft data from the last 20 seconds |
|
712 | - * |
|
713 | - * @return Array the tracker data |
|
714 | - * |
|
715 | - */ |
|
711 | + * Gets the aircraft data from the last 20 seconds |
|
712 | + * |
|
713 | + * @return Array the tracker data |
|
714 | + * |
|
715 | + */ |
|
716 | 716 | public function getRealTimeData($q = '') |
717 | 717 | { |
718 | 718 | global $globalDBdriver; |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
749 | - * Gets all number of flight over countries |
|
750 | - * |
|
751 | - * @return Array the airline country list |
|
752 | - * |
|
753 | - */ |
|
749 | + * Gets all number of flight over countries |
|
750 | + * |
|
751 | + * @return Array the airline country list |
|
752 | + * |
|
753 | + */ |
|
754 | 754 | public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
755 | 755 | { |
756 | 756 | global $globalDBdriver, $globalArchive; |
@@ -820,11 +820,11 @@ discard block |
||
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
823 | - * Gets all callsigns that have flown over |
|
824 | - * |
|
825 | - * @return Array the callsign list |
|
826 | - * |
|
827 | - */ |
|
823 | + * Gets all callsigns that have flown over |
|
824 | + * |
|
825 | + * @return Array the callsign list |
|
826 | + * |
|
827 | + */ |
|
828 | 828 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
829 | 829 | { |
830 | 830 | global $globalDBdriver; |
@@ -891,11 +891,11 @@ discard block |
||
891 | 891 | |
892 | 892 | |
893 | 893 | /** |
894 | - * Counts all dates |
|
895 | - * |
|
896 | - * @return Array the date list |
|
897 | - * |
|
898 | - */ |
|
894 | + * Counts all dates |
|
895 | + * |
|
896 | + * @return Array the date list |
|
897 | + * |
|
898 | + */ |
|
899 | 899 | public function countAllDates($filters = array()) |
900 | 900 | { |
901 | 901 | global $globalTimezone, $globalDBdriver; |
@@ -941,11 +941,11 @@ discard block |
||
941 | 941 | |
942 | 942 | |
943 | 943 | /** |
944 | - * Counts all dates during the last 7 days |
|
945 | - * |
|
946 | - * @return Array the date list |
|
947 | - * |
|
948 | - */ |
|
944 | + * Counts all dates during the last 7 days |
|
945 | + * |
|
946 | + * @return Array the date list |
|
947 | + * |
|
948 | + */ |
|
949 | 949 | public function countAllDatesLast7Days($filters = array()) |
950 | 950 | { |
951 | 951 | global $globalTimezone, $globalDBdriver; |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $query .= " GROUP BY date_name |
968 | 968 | ORDER BY date_name ASC"; |
969 | 969 | $query_data = array(':offset' => $offset); |
970 | - } |
|
970 | + } |
|
971 | 971 | |
972 | 972 | $sth = $this->db->prepare($query); |
973 | 973 | $sth->execute($query_data); |
@@ -987,11 +987,11 @@ discard block |
||
987 | 987 | } |
988 | 988 | |
989 | 989 | /** |
990 | - * Counts all dates during the last month |
|
991 | - * |
|
992 | - * @return Array the date list |
|
993 | - * |
|
994 | - */ |
|
990 | + * Counts all dates during the last month |
|
991 | + * |
|
992 | + * @return Array the date list |
|
993 | + * |
|
994 | + */ |
|
995 | 995 | public function countAllDatesLastMonth($filters = array()) |
996 | 996 | { |
997 | 997 | global $globalTimezone, $globalDBdriver; |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $query .= " GROUP BY date_name |
1014 | 1014 | ORDER BY date_name ASC"; |
1015 | 1015 | $query_data = array(':offset' => $offset); |
1016 | - } |
|
1016 | + } |
|
1017 | 1017 | |
1018 | 1018 | $sth = $this->db->prepare($query); |
1019 | 1019 | $sth->execute($query_data); |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | /** |
1038 | - * Counts all month |
|
1039 | - * |
|
1040 | - * @return Array the month list |
|
1041 | - * |
|
1042 | - */ |
|
1038 | + * Counts all month |
|
1039 | + * |
|
1040 | + * @return Array the month list |
|
1041 | + * |
|
1042 | + */ |
|
1043 | 1043 | public function countAllMonths($filters = array()) |
1044 | 1044 | { |
1045 | 1045 | global $globalTimezone, $globalDBdriver; |
@@ -1084,11 +1084,11 @@ discard block |
||
1084 | 1084 | |
1085 | 1085 | |
1086 | 1086 | /** |
1087 | - * Counts all dates during the last year |
|
1088 | - * |
|
1089 | - * @return Array the date list |
|
1090 | - * |
|
1091 | - */ |
|
1087 | + * Counts all dates during the last year |
|
1088 | + * |
|
1089 | + * @return Array the date list |
|
1090 | + * |
|
1091 | + */ |
|
1092 | 1092 | public function countAllMonthsLastYear($filters) |
1093 | 1093 | { |
1094 | 1094 | global $globalTimezone, $globalDBdriver; |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | $query .= " GROUP BY year_name, month_name |
1111 | 1111 | ORDER BY year_name, month_name ASC"; |
1112 | 1112 | $query_data = array(':offset' => $offset); |
1113 | - } |
|
1113 | + } |
|
1114 | 1114 | |
1115 | 1115 | $sth = $this->db->prepare($query); |
1116 | 1116 | $sth->execute($query_data); |
@@ -1133,11 +1133,11 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | |
1135 | 1135 | /** |
1136 | - * Counts all hours |
|
1137 | - * |
|
1138 | - * @return Array the hour list |
|
1139 | - * |
|
1140 | - */ |
|
1136 | + * Counts all hours |
|
1137 | + * |
|
1138 | + * @return Array the hour list |
|
1139 | + * |
|
1140 | + */ |
|
1141 | 1141 | public function countAllHours($orderby,$filters = array()) |
1142 | 1142 | { |
1143 | 1143 | global $globalTimezone, $globalDBdriver; |
@@ -1200,11 +1200,11 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | |
1202 | 1202 | /** |
1203 | - * Counts all hours by date |
|
1204 | - * |
|
1205 | - * @return Array the hour list |
|
1206 | - * |
|
1207 | - */ |
|
1203 | + * Counts all hours by date |
|
1204 | + * |
|
1205 | + * @return Array the hour list |
|
1206 | + * |
|
1207 | + */ |
|
1208 | 1208 | public function countAllHoursByDate($date, $filters = array()) |
1209 | 1209 | { |
1210 | 1210 | global $globalTimezone, $globalDBdriver; |
@@ -1248,11 +1248,11 @@ discard block |
||
1248 | 1248 | |
1249 | 1249 | |
1250 | 1250 | /** |
1251 | - * Counts all hours by a ident/callsign |
|
1252 | - * |
|
1253 | - * @return Array the hour list |
|
1254 | - * |
|
1255 | - */ |
|
1251 | + * Counts all hours by a ident/callsign |
|
1252 | + * |
|
1253 | + * @return Array the hour list |
|
1254 | + * |
|
1255 | + */ |
|
1256 | 1256 | public function countAllHoursByIdent($ident, $filters = array()) |
1257 | 1257 | { |
1258 | 1258 | global $globalTimezone, $globalDBdriver; |
@@ -1297,11 +1297,11 @@ discard block |
||
1297 | 1297 | |
1298 | 1298 | |
1299 | 1299 | /** |
1300 | - * Counts all trackers that have flown over |
|
1301 | - * |
|
1302 | - * @return Integer the number of trackers |
|
1303 | - * |
|
1304 | - */ |
|
1300 | + * Counts all trackers that have flown over |
|
1301 | + * |
|
1302 | + * @return Integer the number of trackers |
|
1303 | + * |
|
1304 | + */ |
|
1305 | 1305 | public function countOverallTracker($filters = array(),$year = '',$month = '') |
1306 | 1306 | { |
1307 | 1307 | global $globalDBdriver; |
@@ -1336,11 +1336,11 @@ discard block |
||
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
1339 | - * Counts all trackers type that have flown over |
|
1340 | - * |
|
1341 | - * @return Integer the number of flights |
|
1342 | - * |
|
1343 | - */ |
|
1339 | + * Counts all trackers type that have flown over |
|
1340 | + * |
|
1341 | + * @return Integer the number of flights |
|
1342 | + * |
|
1343 | + */ |
|
1344 | 1344 | public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
1345 | 1345 | { |
1346 | 1346 | global $globalDBdriver; |
@@ -1375,11 +1375,11 @@ discard block |
||
1375 | 1375 | |
1376 | 1376 | |
1377 | 1377 | /** |
1378 | - * Counts all hours of today |
|
1379 | - * |
|
1380 | - * @return Array the hour list |
|
1381 | - * |
|
1382 | - */ |
|
1378 | + * Counts all hours of today |
|
1379 | + * |
|
1380 | + * @return Array the hour list |
|
1381 | + * |
|
1382 | + */ |
|
1383 | 1383 | public function countAllHoursFromToday($filters = array()) |
1384 | 1384 | { |
1385 | 1385 | global $globalTimezone, $globalDBdriver; |
@@ -1419,12 +1419,12 @@ discard block |
||
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | |
1422 | - /** |
|
1423 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1424 | - * |
|
1425 | - * @return Integer the Barrie Spotter ID |
|
1422 | + /** |
|
1423 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1424 | + * |
|
1425 | + * @return Integer the Barrie Spotter ID |
|
1426 | 1426 | q * |
1427 | - */ |
|
1427 | + */ |
|
1428 | 1428 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1429 | 1429 | { |
1430 | 1430 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1445,13 +1445,13 @@ discard block |
||
1445 | 1445 | |
1446 | 1446 | |
1447 | 1447 | /** |
1448 | - * Parses a date string |
|
1449 | - * |
|
1450 | - * @param String $dateString the date string |
|
1451 | - * @param String $timezone the timezone of a user |
|
1452 | - * @return Array the time information |
|
1453 | - * |
|
1454 | - */ |
|
1448 | + * Parses a date string |
|
1449 | + * |
|
1450 | + * @param String $dateString the date string |
|
1451 | + * @param String $timezone the timezone of a user |
|
1452 | + * @return Array the time information |
|
1453 | + * |
|
1454 | + */ |
|
1455 | 1455 | public function parseDateString($dateString, $timezone = '') |
1456 | 1456 | { |
1457 | 1457 | $time_array = array(); |
@@ -1484,12 +1484,12 @@ discard block |
||
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
1487 | - * Parses the direction degrees to working |
|
1488 | - * |
|
1489 | - * @param Float $direction the direction in degrees |
|
1490 | - * @return Array the direction information |
|
1491 | - * |
|
1492 | - */ |
|
1487 | + * Parses the direction degrees to working |
|
1488 | + * |
|
1489 | + * @param Float $direction the direction in degrees |
|
1490 | + * @return Array the direction information |
|
1491 | + * |
|
1492 | + */ |
|
1493 | 1493 | public function parseDirection($direction = 0) |
1494 | 1494 | { |
1495 | 1495 | if ($direction == '') $direction = 0; |
@@ -1568,12 +1568,12 @@ discard block |
||
1568 | 1568 | |
1569 | 1569 | |
1570 | 1570 | /** |
1571 | - * Gets Country from latitude/longitude |
|
1572 | - * |
|
1573 | - * @param Float $latitude latitute of the flight |
|
1574 | - * @param Float $longitude longitute of the flight |
|
1575 | - * @return String the countrie |
|
1576 | - */ |
|
1571 | + * Gets Country from latitude/longitude |
|
1572 | + * |
|
1573 | + * @param Float $latitude latitute of the flight |
|
1574 | + * @param Float $longitude longitute of the flight |
|
1575 | + * @return String the countrie |
|
1576 | + */ |
|
1577 | 1577 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1578 | 1578 | { |
1579 | 1579 | global $globalDBdriver, $globalDebug; |
@@ -1610,11 +1610,11 @@ discard block |
||
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | /** |
1613 | - * Gets Country from iso2 |
|
1614 | - * |
|
1615 | - * @param String $iso2 ISO2 country code |
|
1616 | - * @return String the countrie |
|
1617 | - */ |
|
1613 | + * Gets Country from iso2 |
|
1614 | + * |
|
1615 | + * @param String $iso2 ISO2 country code |
|
1616 | + * @return String the countrie |
|
1617 | + */ |
|
1618 | 1618 | public function getCountryFromISO2($iso2) |
1619 | 1619 | { |
1620 | 1620 | global $globalDBdriver, $globalDebug; |
@@ -1642,11 +1642,11 @@ discard block |
||
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | /** |
1645 | - * Gets all vessels types that have flown over |
|
1646 | - * |
|
1647 | - * @return Array the vessel type list |
|
1648 | - * |
|
1649 | - */ |
|
1645 | + * Gets all vessels types that have flown over |
|
1646 | + * |
|
1647 | + * @return Array the vessel type list |
|
1648 | + * |
|
1649 | + */ |
|
1650 | 1650 | public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1651 | 1651 | { |
1652 | 1652 | global $globalDBdriver; |
@@ -1711,11 +1711,11 @@ discard block |
||
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | /** |
1714 | - * Gets all the tracker information |
|
1715 | - * |
|
1716 | - * @return Array the tracker information |
|
1717 | - * |
|
1718 | - */ |
|
1714 | + * Gets all the tracker information |
|
1715 | + * |
|
1716 | + * @return Array the tracker information |
|
1717 | + * |
|
1718 | + */ |
|
1719 | 1719 | public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1720 | 1720 | { |
1721 | 1721 | global $globalTimezone, $globalDBdriver; |
@@ -1820,12 +1820,12 @@ discard block |
||
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | /** |
1823 | - * Gets the short url from bit.ly |
|
1824 | - * |
|
1825 | - * @param String $url the full url |
|
1826 | - * @return String the bit.ly url |
|
1827 | - * |
|
1828 | - */ |
|
1823 | + * Gets the short url from bit.ly |
|
1824 | + * |
|
1825 | + * @param String $url the full url |
|
1826 | + * @return String the bit.ly url |
|
1827 | + * |
|
1828 | + */ |
|
1829 | 1829 | public function getBitlyURL($url) |
1830 | 1830 | { |
1831 | 1831 | global $globalBitlyAccessToken; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_tracker_query = "SELECT tracker_output.* FROM tracker_output"; |
6 | 6 | |
7 | -class Tracker{ |
|
7 | +class Tracker { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -19,33 +19,33 @@ discard block |
||
19 | 19 | * @return Array the SQL part |
20 | 20 | */ |
21 | 21 | |
22 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
22 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
24 | 24 | $filters = array(); |
25 | 25 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
26 | 26 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
27 | 27 | $filters = $globalStatsFilters[$globalFilterName]; |
28 | 28 | } else { |
29 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
29 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | if (isset($filter[0]['source'])) { |
33 | - $filters = array_merge($filters,$filter); |
|
33 | + $filters = array_merge($filters, $filter); |
|
34 | 34 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
36 | 36 | $filter_query_join = ''; |
37 | 37 | $filter_query_where = ''; |
38 | - foreach($filters as $flt) { |
|
38 | + foreach ($filters as $flt) { |
|
39 | 39 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($filter['source']) && !empty($filter['source'])) { |
48 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
48 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
49 | 49 | } |
50 | 50 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
51 | 51 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
78 | 78 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
79 | 79 | if ($filter_query_where != '') { |
80 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
80 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
81 | 81 | } |
82 | 82 | $filter_query = $filter_query_join.$filter_query_where; |
83 | 83 | return $filter_query; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return Array the tracker information |
93 | 93 | * |
94 | 94 | */ |
95 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
95 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
96 | 96 | { |
97 | 97 | date_default_timezone_set('UTC'); |
98 | 98 | if (!is_string($query)) |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | $sth = $this->db->prepare($query.$limitQuery); |
113 | 113 | $sth->execute($params); |
114 | 114 | } catch (PDOException $e) { |
115 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
115 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
116 | 116 | exit(); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $num_rows = 0; |
120 | 120 | $tracker_array = array(); |
121 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
121 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
122 | 122 | { |
123 | 123 | $num_rows++; |
124 | 124 | $temp_array = array(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | { |
175 | 175 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
176 | 176 | } else { |
177 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
177 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
178 | 178 | } |
179 | 179 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
180 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
181 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
180 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
181 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
182 | 182 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
183 | 183 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
184 | 184 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
185 | 185 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
186 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
187 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
186 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
187 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
188 | 188 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
189 | 189 | } |
190 | 190 | } |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | { |
222 | 222 | $limit_array = explode(",", $limit); |
223 | 223 | |
224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
226 | 226 | |
227 | 227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
228 | 228 | { |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
240 | 240 | } |
241 | 241 | |
242 | - $query = $global_tracker_query.$filter_query." ".$orderby_query; |
|
242 | + $query = $global_tracker_query.$filter_query." ".$orderby_query; |
|
243 | 243 | |
244 | - $tracker_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
244 | + $tracker_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
245 | 245 | |
246 | 246 | return $tracker_array; |
247 | 247 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | if ($id == '') return array(); |
261 | 261 | $additional_query = "tracker_output.famtrackid = :id"; |
262 | 262 | $query_values = array(':id' => $id); |
263 | - $query = $global_tracker_query." WHERE ".$additional_query." "; |
|
264 | - $tracker_array = $this->getDataFromDB($query,$query_values); |
|
263 | + $query = $global_tracker_query." WHERE ".$additional_query." "; |
|
264 | + $tracker_array = $this->getDataFromDB($query, $query_values); |
|
265 | 265 | return $tracker_array; |
266 | 266 | } |
267 | 267 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $query_values = array(); |
281 | 281 | $limit_query = ''; |
282 | 282 | $additional_query = ''; |
283 | - $filter_query = $this->getFilter($filter,true,true); |
|
283 | + $filter_query = $this->getFilter($filter, true, true); |
|
284 | 284 | if ($ident != "") |
285 | 285 | { |
286 | 286 | if (!is_string($ident)) |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | { |
297 | 297 | $limit_array = explode(",", $limit); |
298 | 298 | |
299 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
300 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
299 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
300 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
301 | 301 | |
302 | 302 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
303 | 303 | { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | return $tracker_array; |
322 | 322 | } |
323 | 323 | |
324 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
324 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
325 | 325 | { |
326 | 326 | global $global_tracker_query, $globalTimezone, $globalDBdriver; |
327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $limit_query = ''; |
330 | 330 | $additional_query = ''; |
331 | 331 | |
332 | - $filter_query = $this->getFilter($filter,true,true); |
|
332 | + $filter_query = $this->getFilter($filter, true, true); |
|
333 | 333 | |
334 | 334 | if ($date != "") |
335 | 335 | { |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | { |
356 | 356 | $limit_array = explode(",", $limit); |
357 | 357 | |
358 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
359 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
358 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
360 | 360 | |
361 | 361 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
362 | 362 | { |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | * @return Array list of source name |
388 | 388 | * |
389 | 389 | */ |
390 | - public function getAllSourceName($type = '',$filters = array()) |
|
390 | + public function getAllSourceName($type = '', $filters = array()) |
|
391 | 391 | { |
392 | - $filter_query = $this->getFilter($filters,true,true); |
|
392 | + $filter_query = $this->getFilter($filters, true, true); |
|
393 | 393 | $query_values = array(); |
394 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
394 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
395 | 395 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
396 | 396 | if ($type != '') { |
397 | 397 | $query_values = array(':type' => $type); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $source_array = array(); |
407 | 407 | $temp_array = array(); |
408 | 408 | |
409 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
409 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
410 | 410 | { |
411 | 411 | $temp_array['source_name'] = $row['source_name']; |
412 | 412 | $source_array[] = $temp_array; |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function getAllIdents($filters = array()) |
425 | 425 | { |
426 | - $filter_query = $this->getFilter($filters,true,true); |
|
427 | - $query = "SELECT DISTINCT tracker_output.ident |
|
426 | + $filter_query = $this->getFilter($filters, true, true); |
|
427 | + $query = "SELECT DISTINCT tracker_output.ident |
|
428 | 428 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
429 | 429 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $ident_array = array(); |
435 | 435 | $temp_array = array(); |
436 | 436 | |
437 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
437 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
438 | 438 | { |
439 | 439 | $temp_array['ident'] = $row['ident']; |
440 | 440 | $ident_array[] = $temp_array; |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | } else $offset = '+00:00'; |
460 | 460 | |
461 | 461 | if ($globalDBdriver == 'mysql') { |
462 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
462 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
463 | 463 | FROM tracker_output |
464 | 464 | WHERE tracker_output.date <> '' |
465 | 465 | ORDER BY tracker_output.date ASC LIMIT 0,100"; |
466 | 466 | } else { |
467 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
467 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
468 | 468 | FROM tracker_output |
469 | 469 | WHERE tracker_output.date <> '' |
470 | 470 | ORDER BY tracker_output.date ASC LIMIT 0,100"; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $date_array = array(); |
477 | 477 | $temp_array = array(); |
478 | 478 | |
479 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
479 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
480 | 480 | { |
481 | 481 | $temp_array['date'] = $row['date']; |
482 | 482 | |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | * @return String success or false |
496 | 496 | * |
497 | 497 | */ |
498 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
498 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
499 | 499 | { |
500 | 500 | |
501 | 501 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
502 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
502 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
503 | 503 | |
504 | 504 | try { |
505 | 505 | $sth = $this->db->prepare($query); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
524 | 524 | { |
525 | 525 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
526 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
526 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
527 | 527 | |
528 | 528 | try { |
529 | 529 | $sth = $this->db->prepare($query); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @param String $verticalrate vertival rate of flight |
564 | 564 | * @return String success or false |
565 | 565 | */ |
566 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
566 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
567 | 567 | { |
568 | 568 | global $globalURL; |
569 | 569 | |
@@ -631,21 +631,21 @@ discard block |
||
631 | 631 | } |
632 | 632 | |
633 | 633 | |
634 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
634 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
635 | 635 | { |
636 | 636 | $date = date("Y-m-d H:i:s", time()); |
637 | 637 | } |
638 | 638 | |
639 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
640 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
641 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
642 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
643 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
644 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
645 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
646 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
647 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
648 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
639 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
640 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
641 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
642 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
643 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
644 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
645 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
646 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
647 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
648 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
649 | 649 | |
650 | 650 | if ($latitude == '' && $longitude == '') { |
651 | 651 | $latitude = 0; |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | } |
654 | 654 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
655 | 655 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
656 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
656 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
657 | 657 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
658 | 658 | |
659 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
659 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
660 | 660 | |
661 | 661 | try { |
662 | 662 | |
@@ -682,13 +682,13 @@ discard block |
||
682 | 682 | { |
683 | 683 | global $globalDBdriver, $globalTimezone; |
684 | 684 | if ($globalDBdriver == 'mysql') { |
685 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
685 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
686 | 686 | WHERE tracker_output.ident = :ident |
687 | 687 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
688 | 688 | AND tracker_output.date < UTC_TIMESTAMP()"; |
689 | 689 | $query_data = array(':ident' => $ident); |
690 | 690 | } else { |
691 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
691 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
692 | 692 | WHERE tracker_output.ident = :ident |
693 | 693 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
694 | 694 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | |
698 | 698 | $sth = $this->db->prepare($query); |
699 | 699 | $sth->execute($query_data); |
700 | - $ident_result=''; |
|
701 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
700 | + $ident_result = ''; |
|
701 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
702 | 702 | { |
703 | 703 | $ident_result = $row['ident']; |
704 | 704 | } |
@@ -724,8 +724,8 @@ discard block |
||
724 | 724 | return false; |
725 | 725 | } else { |
726 | 726 | $q_array = explode(" ", $q); |
727 | - foreach ($q_array as $q_item){ |
|
728 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
727 | + foreach ($q_array as $q_item) { |
|
728 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
729 | 729 | $additional_query .= " AND ("; |
730 | 730 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
731 | 731 | $additional_query .= ")"; |
@@ -733,11 +733,11 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | if ($globalDBdriver == 'mysql') { |
736 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
736 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
737 | 737 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
738 | 738 | AND tracker_output.date < UTC_TIMESTAMP()"; |
739 | 739 | } else { |
740 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
740 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
741 | 741 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
742 | 742 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
743 | 743 | } |
@@ -751,16 +751,16 @@ discard block |
||
751 | 751 | * @return Array the airline country list |
752 | 752 | * |
753 | 753 | */ |
754 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
754 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
755 | 755 | { |
756 | 756 | global $globalDBdriver, $globalArchive; |
757 | 757 | //$filter_query = $this->getFilter($filters,true,true); |
758 | - $Connection= new Connection($this->db); |
|
758 | + $Connection = new Connection($this->db); |
|
759 | 759 | if (!$Connection->tableExists('countries')) return array(); |
760 | 760 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
761 | 761 | require_once('class.TrackerLive.php'); |
762 | 762 | $TrackerLive = new TrackerLive($this->db); |
763 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
763 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
764 | 764 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
765 | 765 | if ($olderthanmonths > 0) { |
766 | 766 | if ($globalDBdriver == 'mysql') { |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | } else { |
781 | 781 | require_once('class.TrackerArchive.php'); |
782 | 782 | $TrackerArchive = new TrackerArchive($this->db); |
783 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
783 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
784 | 784 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
785 | 785 | if ($olderthanmonths > 0) { |
786 | 786 | if ($globalDBdriver == 'mysql') { |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | $flight_array = array(); |
809 | 809 | $temp_array = array(); |
810 | 810 | |
811 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
811 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
812 | 812 | { |
813 | 813 | $temp_array['tracker_count'] = $row['nb']; |
814 | 814 | $temp_array['tracker_country'] = $row['name']; |
@@ -825,11 +825,11 @@ discard block |
||
825 | 825 | * @return Array the callsign list |
826 | 826 | * |
827 | 827 | */ |
828 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
828 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
829 | 829 | { |
830 | 830 | global $globalDBdriver; |
831 | - $filter_query = $this->getFilter($filters,true,true); |
|
832 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
831 | + $filter_query = $this->getFilter($filters, true, true); |
|
832 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
833 | 833 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
834 | 834 | if ($olderthanmonths > 0) { |
835 | 835 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -843,28 +843,28 @@ discard block |
||
843 | 843 | if ($year != '') { |
844 | 844 | if ($globalDBdriver == 'mysql') { |
845 | 845 | $query .= " AND YEAR(tracker_output.date) = :year"; |
846 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
846 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
847 | 847 | } else { |
848 | 848 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
849 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
849 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
850 | 850 | } |
851 | 851 | } |
852 | 852 | if ($month != '') { |
853 | 853 | if ($globalDBdriver == 'mysql') { |
854 | 854 | $query .= " AND MONTH(tracker_output.date) = :month"; |
855 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
855 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
856 | 856 | } else { |
857 | 857 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
858 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
858 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | if ($day != '') { |
862 | 862 | if ($globalDBdriver == 'mysql') { |
863 | 863 | $query .= " AND DAY(tracker_output.date) = :day"; |
864 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
864 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
865 | 865 | } else { |
866 | 866 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
867 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
867 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
868 | 868 | } |
869 | 869 | } |
870 | 870 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | $callsign_array = array(); |
877 | 877 | $temp_array = array(); |
878 | 878 | |
879 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
879 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | 880 | { |
881 | 881 | $temp_array['callsign_icao'] = $row['ident']; |
882 | 882 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | $date_array = array(); |
929 | 929 | $temp_array = array(); |
930 | 930 | |
931 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
931 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
932 | 932 | { |
933 | 933 | $temp_array['date_name'] = $row['date_name']; |
934 | 934 | $temp_array['date_count'] = $row['date_count']; |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | $datetime = new DateTime(); |
955 | 955 | $offset = $datetime->format('P'); |
956 | 956 | } else $offset = '+00:00'; |
957 | - $filter_query = $this->getFilter($filters,true,true); |
|
957 | + $filter_query = $this->getFilter($filters, true, true); |
|
958 | 958 | if ($globalDBdriver == 'mysql') { |
959 | 959 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
960 | 960 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | $date_array = array(); |
976 | 976 | $temp_array = array(); |
977 | 977 | |
978 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
978 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
979 | 979 | { |
980 | 980 | $temp_array['date_name'] = $row['date_name']; |
981 | 981 | $temp_array['date_count'] = $row['date_count']; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | $datetime = new DateTime(); |
1001 | 1001 | $offset = $datetime->format('P'); |
1002 | 1002 | } else $offset = '+00:00'; |
1003 | - $filter_query = $this->getFilter($filters,true,true); |
|
1003 | + $filter_query = $this->getFilter($filters, true, true); |
|
1004 | 1004 | if ($globalDBdriver == 'mysql') { |
1005 | 1005 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1006 | 1006 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | $date_array = array(); |
1022 | 1022 | $temp_array = array(); |
1023 | 1023 | |
1024 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1024 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1025 | 1025 | { |
1026 | 1026 | $temp_array['date_name'] = $row['date_name']; |
1027 | 1027 | $temp_array['date_count'] = $row['date_count']; |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | $date_array = array(); |
1069 | 1069 | $temp_array = array(); |
1070 | 1070 | |
1071 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1071 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1072 | 1072 | { |
1073 | 1073 | $temp_array['month_name'] = $row['month_name']; |
1074 | 1074 | $temp_array['year_name'] = $row['year_name']; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $datetime = new DateTime(); |
1098 | 1098 | $offset = $datetime->format('P'); |
1099 | 1099 | } else $offset = '+00:00'; |
1100 | - $filter_query = $this->getFilter($filters,true,true); |
|
1100 | + $filter_query = $this->getFilter($filters, true, true); |
|
1101 | 1101 | if ($globalDBdriver == 'mysql') { |
1102 | 1102 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1103 | 1103 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | $date_array = array(); |
1119 | 1119 | $temp_array = array(); |
1120 | 1120 | |
1121 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1121 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1122 | 1122 | { |
1123 | 1123 | $temp_array['year_name'] = $row['year_name']; |
1124 | 1124 | $temp_array['month_name'] = $row['month_name']; |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | * @return Array the hour list |
1139 | 1139 | * |
1140 | 1140 | */ |
1141 | - public function countAllHours($orderby,$filters = array()) |
|
1141 | + public function countAllHours($orderby, $filters = array()) |
|
1142 | 1142 | { |
1143 | 1143 | global $globalTimezone, $globalDBdriver; |
1144 | 1144 | if ($globalTimezone != '') { |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $hour_array = array(); |
1187 | 1187 | $temp_array = array(); |
1188 | 1188 | |
1189 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1189 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1190 | 1190 | { |
1191 | 1191 | $temp_array['hour_name'] = $row['hour_name']; |
1192 | 1192 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1208,8 +1208,8 @@ discard block |
||
1208 | 1208 | public function countAllHoursByDate($date, $filters = array()) |
1209 | 1209 | { |
1210 | 1210 | global $globalTimezone, $globalDBdriver; |
1211 | - $filter_query = $this->getFilter($filters,true,true); |
|
1212 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1211 | + $filter_query = $this->getFilter($filters, true, true); |
|
1212 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1213 | 1213 | if ($globalTimezone != '') { |
1214 | 1214 | date_default_timezone_set($globalTimezone); |
1215 | 1215 | $datetime = new DateTime($date); |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | } else $offset = '+00:00'; |
1218 | 1218 | |
1219 | 1219 | if ($globalDBdriver == 'mysql') { |
1220 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1220 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1221 | 1221 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1222 | 1222 | GROUP BY hour_name |
1223 | 1223 | ORDER BY hour_name ASC"; |
1224 | 1224 | } else { |
1225 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1225 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1226 | 1226 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1227 | 1227 | GROUP BY hour_name |
1228 | 1228 | ORDER BY hour_name ASC"; |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | $hour_array = array(); |
1235 | 1235 | $temp_array = array(); |
1236 | 1236 | |
1237 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1237 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1238 | 1238 | { |
1239 | 1239 | $temp_array['hour_name'] = $row['hour_name']; |
1240 | 1240 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | public function countAllHoursByIdent($ident, $filters = array()) |
1257 | 1257 | { |
1258 | 1258 | global $globalTimezone, $globalDBdriver; |
1259 | - $filter_query = $this->getFilter($filters,true,true); |
|
1260 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1259 | + $filter_query = $this->getFilter($filters, true, true); |
|
1260 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1261 | 1261 | if ($globalTimezone != '') { |
1262 | 1262 | date_default_timezone_set($globalTimezone); |
1263 | 1263 | $datetime = new DateTime(); |
@@ -1265,12 +1265,12 @@ discard block |
||
1265 | 1265 | } else $offset = '+00:00'; |
1266 | 1266 | |
1267 | 1267 | if ($globalDBdriver == 'mysql') { |
1268 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1268 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1269 | 1269 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1270 | 1270 | GROUP BY hour_name |
1271 | 1271 | ORDER BY hour_name ASC"; |
1272 | 1272 | } else { |
1273 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1273 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1274 | 1274 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1275 | 1275 | GROUP BY hour_name |
1276 | 1276 | ORDER BY hour_name ASC"; |
@@ -1278,12 +1278,12 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | |
1280 | 1280 | $sth = $this->db->prepare($query); |
1281 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1281 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1282 | 1282 | |
1283 | 1283 | $hour_array = array(); |
1284 | 1284 | $temp_array = array(); |
1285 | 1285 | |
1286 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1286 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1287 | 1287 | { |
1288 | 1288 | $temp_array['hour_name'] = $row['hour_name']; |
1289 | 1289 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1302,33 +1302,33 @@ discard block |
||
1302 | 1302 | * @return Integer the number of trackers |
1303 | 1303 | * |
1304 | 1304 | */ |
1305 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
1305 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
1306 | 1306 | { |
1307 | 1307 | global $globalDBdriver; |
1308 | 1308 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
1309 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1309 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1310 | 1310 | $query_values = array(); |
1311 | 1311 | $query = ''; |
1312 | 1312 | if ($year != '') { |
1313 | 1313 | if ($globalDBdriver == 'mysql') { |
1314 | 1314 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1315 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1315 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1316 | 1316 | } else { |
1317 | 1317 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1318 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1318 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 | if ($month != '') { |
1322 | 1322 | if ($globalDBdriver == 'mysql') { |
1323 | 1323 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1324 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1324 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1325 | 1325 | } else { |
1326 | 1326 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1327 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1327 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1328 | 1328 | } |
1329 | 1329 | } |
1330 | 1330 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1331 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1331 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1332 | 1332 | |
1333 | 1333 | $sth = $this->db->prepare($queryi); |
1334 | 1334 | $sth->execute($query_values); |
@@ -1341,32 +1341,32 @@ discard block |
||
1341 | 1341 | * @return Integer the number of flights |
1342 | 1342 | * |
1343 | 1343 | */ |
1344 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
1344 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
1345 | 1345 | { |
1346 | 1346 | global $globalDBdriver; |
1347 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1347 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1348 | 1348 | $query_values = array(); |
1349 | 1349 | $query = ''; |
1350 | 1350 | if ($year != '') { |
1351 | 1351 | if ($globalDBdriver == 'mysql') { |
1352 | 1352 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1353 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1353 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1354 | 1354 | } else { |
1355 | 1355 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1356 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1356 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1357 | 1357 | } |
1358 | 1358 | } |
1359 | 1359 | if ($month != '') { |
1360 | 1360 | if ($globalDBdriver == 'mysql') { |
1361 | 1361 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1362 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1362 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1363 | 1363 | } else { |
1364 | 1364 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1365 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1365 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1366 | 1366 | } |
1367 | 1367 | } |
1368 | 1368 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1369 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1369 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1370 | 1370 | |
1371 | 1371 | $sth = $this->db->prepare($queryi); |
1372 | 1372 | $sth->execute($query_values); |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | public function countAllHoursFromToday($filters = array()) |
1384 | 1384 | { |
1385 | 1385 | global $globalTimezone, $globalDBdriver; |
1386 | - $filter_query = $this->getFilter($filters,true,true); |
|
1386 | + $filter_query = $this->getFilter($filters, true, true); |
|
1387 | 1387 | if ($globalTimezone != '') { |
1388 | 1388 | date_default_timezone_set($globalTimezone); |
1389 | 1389 | $datetime = new DateTime(); |
@@ -1391,12 +1391,12 @@ discard block |
||
1391 | 1391 | } else $offset = '+00:00'; |
1392 | 1392 | |
1393 | 1393 | if ($globalDBdriver == 'mysql') { |
1394 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1394 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1395 | 1395 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1396 | 1396 | GROUP BY hour_name |
1397 | 1397 | ORDER BY hour_name ASC"; |
1398 | 1398 | } else { |
1399 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1399 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1400 | 1400 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1401 | 1401 | GROUP BY hour_name |
1402 | 1402 | ORDER BY hour_name ASC"; |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | $hour_array = array(); |
1409 | 1409 | $temp_array = array(); |
1410 | 1410 | |
1411 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1411 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1412 | 1412 | { |
1413 | 1413 | $temp_array['hour_name'] = $row['hour_name']; |
1414 | 1414 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1427,9 +1427,9 @@ discard block |
||
1427 | 1427 | */ |
1428 | 1428 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1429 | 1429 | { |
1430 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1430 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1431 | 1431 | |
1432 | - $query = "SELECT tracker_output.tracker_id |
|
1432 | + $query = "SELECT tracker_output.tracker_id |
|
1433 | 1433 | FROM tracker_output |
1434 | 1434 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1435 | 1435 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | $sth = $this->db->prepare($query); |
1438 | 1438 | $sth->execute(); |
1439 | 1439 | |
1440 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1440 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1441 | 1441 | { |
1442 | 1442 | return $row['tracker_id']; |
1443 | 1443 | } |
@@ -1462,23 +1462,23 @@ discard block |
||
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | $current_date = date("Y-m-d H:i:s"); |
1465 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1465 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1466 | 1466 | |
1467 | 1467 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1468 | 1468 | |
1469 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1469 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1470 | 1470 | $years = $time_array['years']; |
1471 | 1471 | |
1472 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1472 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1473 | 1473 | $months = $time_array['months']; |
1474 | 1474 | |
1475 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1475 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1476 | 1476 | $days = $time_array['days']; |
1477 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1477 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1478 | 1478 | $hours = $time_array['hours']; |
1479 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1479 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1480 | 1480 | $minutes = $time_array['minutes']; |
1481 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1481 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1482 | 1482 | |
1483 | 1483 | return $time_array; |
1484 | 1484 | } |
@@ -1501,63 +1501,63 @@ discard block |
||
1501 | 1501 | $temp_array['direction_degree'] = $direction; |
1502 | 1502 | $temp_array['direction_shortname'] = "N"; |
1503 | 1503 | $temp_array['direction_fullname'] = "North"; |
1504 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1504 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1505 | 1505 | $temp_array['direction_degree'] = $direction; |
1506 | 1506 | $temp_array['direction_shortname'] = "NNE"; |
1507 | 1507 | $temp_array['direction_fullname'] = "North-Northeast"; |
1508 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1508 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1509 | 1509 | $temp_array['direction_degree'] = $direction; |
1510 | 1510 | $temp_array['direction_shortname'] = "NE"; |
1511 | 1511 | $temp_array['direction_fullname'] = "Northeast"; |
1512 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1512 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1513 | 1513 | $temp_array['direction_degree'] = $direction; |
1514 | 1514 | $temp_array['direction_shortname'] = "ENE"; |
1515 | 1515 | $temp_array['direction_fullname'] = "East-Northeast"; |
1516 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1516 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1517 | 1517 | $temp_array['direction_degree'] = $direction; |
1518 | 1518 | $temp_array['direction_shortname'] = "E"; |
1519 | 1519 | $temp_array['direction_fullname'] = "East"; |
1520 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1520 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1521 | 1521 | $temp_array['direction_degree'] = $direction; |
1522 | 1522 | $temp_array['direction_shortname'] = "ESE"; |
1523 | 1523 | $temp_array['direction_fullname'] = "East-Southeast"; |
1524 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1524 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1525 | 1525 | $temp_array['direction_degree'] = $direction; |
1526 | 1526 | $temp_array['direction_shortname'] = "SE"; |
1527 | 1527 | $temp_array['direction_fullname'] = "Southeast"; |
1528 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1528 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1529 | 1529 | $temp_array['direction_degree'] = $direction; |
1530 | 1530 | $temp_array['direction_shortname'] = "SSE"; |
1531 | 1531 | $temp_array['direction_fullname'] = "South-Southeast"; |
1532 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1532 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1533 | 1533 | $temp_array['direction_degree'] = $direction; |
1534 | 1534 | $temp_array['direction_shortname'] = "S"; |
1535 | 1535 | $temp_array['direction_fullname'] = "South"; |
1536 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1536 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1537 | 1537 | $temp_array['direction_degree'] = $direction; |
1538 | 1538 | $temp_array['direction_shortname'] = "SSW"; |
1539 | 1539 | $temp_array['direction_fullname'] = "South-Southwest"; |
1540 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1540 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1541 | 1541 | $temp_array['direction_degree'] = $direction; |
1542 | 1542 | $temp_array['direction_shortname'] = "SW"; |
1543 | 1543 | $temp_array['direction_fullname'] = "Southwest"; |
1544 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1544 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1545 | 1545 | $temp_array['direction_degree'] = $direction; |
1546 | 1546 | $temp_array['direction_shortname'] = "WSW"; |
1547 | 1547 | $temp_array['direction_fullname'] = "West-Southwest"; |
1548 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1548 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1549 | 1549 | $temp_array['direction_degree'] = $direction; |
1550 | 1550 | $temp_array['direction_shortname'] = "W"; |
1551 | 1551 | $temp_array['direction_fullname'] = "West"; |
1552 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1552 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1553 | 1553 | $temp_array['direction_degree'] = $direction; |
1554 | 1554 | $temp_array['direction_shortname'] = "WNW"; |
1555 | 1555 | $temp_array['direction_fullname'] = "West-Northwest"; |
1556 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1556 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1557 | 1557 | $temp_array['direction_degree'] = $direction; |
1558 | 1558 | $temp_array['direction_shortname'] = "NW"; |
1559 | 1559 | $temp_array['direction_fullname'] = "Northwest"; |
1560 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1560 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1561 | 1561 | $temp_array['direction_degree'] = $direction; |
1562 | 1562 | $temp_array['direction_shortname'] = "NNW"; |
1563 | 1563 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1574,11 +1574,11 @@ discard block |
||
1574 | 1574 | * @param Float $longitude longitute of the flight |
1575 | 1575 | * @return String the countrie |
1576 | 1576 | */ |
1577 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1577 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1578 | 1578 | { |
1579 | 1579 | global $globalDBdriver, $globalDebug; |
1580 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1581 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1580 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1581 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1582 | 1582 | |
1583 | 1583 | $Connection = new Connection($this->db); |
1584 | 1584 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | public function getCountryFromISO2($iso2) |
1619 | 1619 | { |
1620 | 1620 | global $globalDBdriver, $globalDebug; |
1621 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1621 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1622 | 1622 | |
1623 | 1623 | $Connection = new Connection($this->db); |
1624 | 1624 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1647,11 +1647,11 @@ discard block |
||
1647 | 1647 | * @return Array the vessel type list |
1648 | 1648 | * |
1649 | 1649 | */ |
1650 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1650 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1651 | 1651 | { |
1652 | 1652 | global $globalDBdriver; |
1653 | - $filter_query = $this->getFilter($filters,true,true); |
|
1654 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1653 | + $filter_query = $this->getFilter($filters, true, true); |
|
1654 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1655 | 1655 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
1656 | 1656 | if ($olderthanmonths > 0) { |
1657 | 1657 | if ($globalDBdriver == 'mysql') { |
@@ -1671,28 +1671,28 @@ discard block |
||
1671 | 1671 | if ($year != '') { |
1672 | 1672 | if ($globalDBdriver == 'mysql') { |
1673 | 1673 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1674 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1674 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1675 | 1675 | } else { |
1676 | 1676 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1677 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1677 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | if ($month != '') { |
1681 | 1681 | if ($globalDBdriver == 'mysql') { |
1682 | 1682 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1683 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1683 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1684 | 1684 | } else { |
1685 | 1685 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1686 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1686 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1687 | 1687 | } |
1688 | 1688 | } |
1689 | 1689 | if ($day != '') { |
1690 | 1690 | if ($globalDBdriver == 'mysql') { |
1691 | 1691 | $query .= " AND DAY(tracker_output.date) = :day"; |
1692 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1692 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1693 | 1693 | } else { |
1694 | 1694 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
1695 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1695 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | $sth->execute($query_values); |
1702 | 1702 | $tracker_array = array(); |
1703 | 1703 | $temp_array = array(); |
1704 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1704 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1705 | 1705 | { |
1706 | 1706 | $temp_array['tracker_type'] = $row['tracker_type']; |
1707 | 1707 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1716,13 +1716,13 @@ discard block |
||
1716 | 1716 | * @return Array the tracker information |
1717 | 1717 | * |
1718 | 1718 | */ |
1719 | - public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1719 | + public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1720 | 1720 | { |
1721 | 1721 | global $globalTimezone, $globalDBdriver; |
1722 | 1722 | date_default_timezone_set('UTC'); |
1723 | 1723 | $query_values = array(); |
1724 | 1724 | $additional_query = ''; |
1725 | - $filter_query = $this->getFilter($filters,true,true); |
|
1725 | + $filter_query = $this->getFilter($filters, true, true); |
|
1726 | 1726 | if ($q != "") |
1727 | 1727 | { |
1728 | 1728 | if (!is_string($q)) |
@@ -1730,8 +1730,8 @@ discard block |
||
1730 | 1730 | return false; |
1731 | 1731 | } else { |
1732 | 1732 | $q_array = explode(" ", $q); |
1733 | - foreach ($q_array as $q_item){ |
|
1734 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1733 | + foreach ($q_array as $q_item) { |
|
1734 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1735 | 1735 | $additional_query .= " AND ("; |
1736 | 1736 | if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
1737 | 1737 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
@@ -1741,20 +1741,20 @@ discard block |
||
1741 | 1741 | } |
1742 | 1742 | if ($callsign != "") |
1743 | 1743 | { |
1744 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1744 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1745 | 1745 | if (!is_string($callsign)) |
1746 | 1746 | { |
1747 | 1747 | return false; |
1748 | 1748 | } else { |
1749 | 1749 | $additional_query .= " AND tracker_output.ident = :callsign"; |
1750 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1750 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | if ($date_posted != "") |
1754 | 1754 | { |
1755 | 1755 | $date_array = explode(",", $date_posted); |
1756 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1757 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1756 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1757 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1758 | 1758 | if ($globalTimezone != '') { |
1759 | 1759 | date_default_timezone_set($globalTimezone); |
1760 | 1760 | $datetime = new DateTime(); |
@@ -1781,8 +1781,8 @@ discard block |
||
1781 | 1781 | if ($limit != "") |
1782 | 1782 | { |
1783 | 1783 | $limit_array = explode(",", $limit); |
1784 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1785 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1784 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1785 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1786 | 1786 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1787 | 1787 | { |
1788 | 1788 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1800,22 +1800,22 @@ discard block |
||
1800 | 1800 | } |
1801 | 1801 | } |
1802 | 1802 | if ($origLat != "" && $origLon != "" && $dist != "") { |
1803 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
1803 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
1804 | 1804 | if ($globalDBdriver == 'mysql') { |
1805 | - $query="SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
1805 | + $query = "SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
1806 | 1806 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND tracker_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and tracker_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1807 | 1807 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
1808 | 1808 | } else { |
1809 | - $query="SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
1809 | + $query = "SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
1810 | 1810 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1811 | 1811 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
1812 | 1812 | } |
1813 | 1813 | } else { |
1814 | - $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
1814 | + $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
1815 | 1815 | ".$additional_query." |
1816 | 1816 | ".$orderby_query; |
1817 | 1817 | } |
1818 | - $tracker_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
1818 | + $tracker_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1819 | 1819 | return $tracker_array; |
1820 | 1820 | } |
1821 | 1821 | |
@@ -1840,7 +1840,7 @@ discard block |
||
1840 | 1840 | curl_close($ch); |
1841 | 1841 | $bitly_data = json_decode($bitly_data); |
1842 | 1842 | $bitly_url = ''; |
1843 | - if ($bitly_data->status_txt = "OK"){ |
|
1843 | + if ($bitly_data->status_txt = "OK") { |
|
1844 | 1844 | $bitly_url = $bitly_data->data->url; |
1845 | 1845 | } |
1846 | 1846 | return $bitly_url; |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | |
1849 | 1849 | public function getOrderBy() |
1850 | 1850 | { |
1851 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1851 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1852 | 1852 | |
1853 | 1853 | return $orderby; |
1854 | 1854 |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection. (Tracker)'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -74,8 +78,11 @@ discard block |
||
74 | 78 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
75 | 79 | } |
76 | 80 | } |
77 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
78 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
81 | + if ($filter_query_where == '' && $where) { |
|
82 | + $filter_query_where = ' WHERE'; |
|
83 | + } elseif ($filter_query_where != '' && $and) { |
|
84 | + $filter_query_where .= ' AND'; |
|
85 | + } |
|
79 | 86 | if ($filter_query_where != '') { |
80 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
81 | 88 | } |
@@ -129,26 +136,43 @@ discard block |
||
129 | 136 | $temp_array['tracker_id'] = $row['tracker_archive_id']; |
130 | 137 | } elseif (isset($row['tracker_archive_output_id'])) { |
131 | 138 | $temp_array['tracker_id'] = $row['tracker_archive_output_id']; |
132 | - */} |
|
133 | - elseif (isset($row['trackerid'])) { |
|
139 | + */} elseif (isset($row['trackerid'])) { |
|
134 | 140 | $temp_array['trackerid'] = $row['trackerid']; |
135 | 141 | } else { |
136 | 142 | $temp_array['trackerid'] = ''; |
137 | 143 | } |
138 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
139 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
140 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
144 | + if (isset($row['famtrackid'])) { |
|
145 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
146 | + } |
|
147 | + if (isset($row['type'])) { |
|
148 | + $temp_array['type'] = $row['type']; |
|
149 | + } |
|
150 | + if (isset($row['comment'])) { |
|
151 | + $temp_array['comment'] = $row['comment']; |
|
152 | + } |
|
141 | 153 | $temp_array['ident'] = $row['ident']; |
142 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
143 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
144 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
145 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
154 | + if (isset($row['latitude'])) { |
|
155 | + $temp_array['latitude'] = $row['latitude']; |
|
156 | + } |
|
157 | + if (isset($row['longitude'])) { |
|
158 | + $temp_array['longitude'] = $row['longitude']; |
|
159 | + } |
|
160 | + if (isset($row['format_source'])) { |
|
161 | + $temp_array['format_source'] = $row['format_source']; |
|
162 | + } |
|
163 | + if (isset($row['altitude'])) { |
|
164 | + $temp_array['altitude'] = $row['altitude']; |
|
165 | + } |
|
146 | 166 | if (isset($row['heading'])) { |
147 | 167 | $temp_array['heading'] = $row['heading']; |
148 | 168 | $heading_direction = $this->parseDirection($row['heading']); |
149 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
169 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
171 | + } |
|
172 | + } |
|
173 | + if (isset($row['ground_speed'])) { |
|
174 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
150 | 175 | } |
151 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
152 | 176 | |
153 | 177 | if (isset($row['date'])) { |
154 | 178 | $dateArray = $this->parseDateString($row['date']); |
@@ -191,13 +215,21 @@ discard block |
||
191 | 215 | } |
192 | 216 | |
193 | 217 | $fromsource = NULL; |
194 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
195 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
196 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
218 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
219 | + $temp_array['source_name'] = $row['source_name']; |
|
220 | + } |
|
221 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
222 | + $temp_array['over_country'] = $row['over_country']; |
|
223 | + } |
|
224 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
225 | + $temp_array['distance'] = $row['distance']; |
|
226 | + } |
|
197 | 227 | $temp_array['query_number_rows'] = $num_rows; |
198 | 228 | $tracker_array[] = $temp_array; |
199 | 229 | } |
200 | - if ($num_rows == 0) return array(); |
|
230 | + if ($num_rows == 0) { |
|
231 | + return array(); |
|
232 | + } |
|
201 | 233 | $tracker_array[0]['query_number_rows'] = $num_rows; |
202 | 234 | return $tracker_array; |
203 | 235 | } |
@@ -228,8 +260,12 @@ discard block |
||
228 | 260 | { |
229 | 261 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
230 | 262 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
231 | - } else $limit_query = ""; |
|
232 | - } else $limit_query = ""; |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
266 | + } else { |
|
267 | + $limit_query = ""; |
|
268 | + } |
|
233 | 269 | |
234 | 270 | if ($sort != "") |
235 | 271 | { |
@@ -257,7 +293,9 @@ discard block |
||
257 | 293 | global $global_tracker_query; |
258 | 294 | |
259 | 295 | date_default_timezone_set('UTC'); |
260 | - if ($id == '') return array(); |
|
296 | + if ($id == '') { |
|
297 | + return array(); |
|
298 | + } |
|
261 | 299 | $additional_query = "tracker_output.famtrackid = :id"; |
262 | 300 | $query_values = array(':id' => $id); |
263 | 301 | $query = $global_tracker_query." WHERE ".$additional_query." "; |
@@ -400,8 +438,11 @@ discard block |
||
400 | 438 | $query .= " ORDER BY tracker_output.source_name ASC"; |
401 | 439 | |
402 | 440 | $sth = $this->db->prepare($query); |
403 | - if (!empty($query_values)) $sth->execute($query_values); |
|
404 | - else $sth->execute(); |
|
441 | + if (!empty($query_values)) { |
|
442 | + $sth->execute($query_values); |
|
443 | + } else { |
|
444 | + $sth->execute(); |
|
445 | + } |
|
405 | 446 | |
406 | 447 | $source_array = array(); |
407 | 448 | $temp_array = array(); |
@@ -456,7 +497,9 @@ discard block |
||
456 | 497 | date_default_timezone_set($globalTimezone); |
457 | 498 | $datetime = new DateTime(); |
458 | 499 | $offset = $datetime->format('P'); |
459 | - } else $offset = '+00:00'; |
|
500 | + } else { |
|
501 | + $offset = '+00:00'; |
|
502 | + } |
|
460 | 503 | |
461 | 504 | if ($globalDBdriver == 'mysql') { |
462 | 505 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -612,7 +655,9 @@ discard block |
||
612 | 655 | { |
613 | 656 | return false; |
614 | 657 | } |
615 | - } else $altitude = 0; |
|
658 | + } else { |
|
659 | + $altitude = 0; |
|
660 | + } |
|
616 | 661 | |
617 | 662 | if ($heading != "") |
618 | 663 | { |
@@ -651,8 +696,12 @@ discard block |
||
651 | 696 | $latitude = 0; |
652 | 697 | $longitude = 0; |
653 | 698 | } |
654 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
655 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
699 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
700 | + $heading = 0; |
|
701 | + } |
|
702 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
703 | + $groundspeed = 0; |
|
704 | + } |
|
656 | 705 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
657 | 706 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
658 | 707 | |
@@ -756,7 +805,9 @@ discard block |
||
756 | 805 | global $globalDBdriver, $globalArchive; |
757 | 806 | //$filter_query = $this->getFilter($filters,true,true); |
758 | 807 | $Connection= new Connection($this->db); |
759 | - if (!$Connection->tableExists('countries')) return array(); |
|
808 | + if (!$Connection->tableExists('countries')) { |
|
809 | + return array(); |
|
810 | + } |
|
760 | 811 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
761 | 812 | require_once('class.TrackerLive.php'); |
762 | 813 | $TrackerLive = new TrackerLive($this->db); |
@@ -799,7 +850,9 @@ discard block |
||
799 | 850 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
800 | 851 | } |
801 | 852 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
802 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
853 | + if ($limit) { |
|
854 | + $query .= " LIMIT 10 OFFSET 0"; |
|
855 | + } |
|
803 | 856 | |
804 | 857 | |
805 | 858 | $sth = $this->db->prepare($query); |
@@ -832,12 +885,18 @@ discard block |
||
832 | 885 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
833 | 886 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
834 | 887 | if ($olderthanmonths > 0) { |
835 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
836 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
888 | + if ($globalDBdriver == 'mysql') { |
|
889 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
890 | + } else { |
|
891 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
892 | + } |
|
837 | 893 | } |
838 | 894 | if ($sincedate != '') { |
839 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
840 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
895 | + if ($globalDBdriver == 'mysql') { |
|
896 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
897 | + } else { |
|
898 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
899 | + } |
|
841 | 900 | } |
842 | 901 | $query_values = array(); |
843 | 902 | if ($year != '') { |
@@ -868,7 +927,9 @@ discard block |
||
868 | 927 | } |
869 | 928 | } |
870 | 929 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
871 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
930 | + if ($limit) { |
|
931 | + $query .= " LIMIT 10 OFFSET 0"; |
|
932 | + } |
|
872 | 933 | |
873 | 934 | $sth = $this->db->prepare($query); |
874 | 935 | $sth->execute($query_values); |
@@ -903,7 +964,9 @@ discard block |
||
903 | 964 | date_default_timezone_set($globalTimezone); |
904 | 965 | $datetime = new DateTime(); |
905 | 966 | $offset = $datetime->format('P'); |
906 | - } else $offset = '+00:00'; |
|
967 | + } else { |
|
968 | + $offset = '+00:00'; |
|
969 | + } |
|
907 | 970 | |
908 | 971 | if ($globalDBdriver == 'mysql') { |
909 | 972 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -953,7 +1016,9 @@ discard block |
||
953 | 1016 | date_default_timezone_set($globalTimezone); |
954 | 1017 | $datetime = new DateTime(); |
955 | 1018 | $offset = $datetime->format('P'); |
956 | - } else $offset = '+00:00'; |
|
1019 | + } else { |
|
1020 | + $offset = '+00:00'; |
|
1021 | + } |
|
957 | 1022 | $filter_query = $this->getFilter($filters,true,true); |
958 | 1023 | if ($globalDBdriver == 'mysql') { |
959 | 1024 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -999,7 +1064,9 @@ discard block |
||
999 | 1064 | date_default_timezone_set($globalTimezone); |
1000 | 1065 | $datetime = new DateTime(); |
1001 | 1066 | $offset = $datetime->format('P'); |
1002 | - } else $offset = '+00:00'; |
|
1067 | + } else { |
|
1068 | + $offset = '+00:00'; |
|
1069 | + } |
|
1003 | 1070 | $filter_query = $this->getFilter($filters,true,true); |
1004 | 1071 | if ($globalDBdriver == 'mysql') { |
1005 | 1072 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1047,7 +1114,9 @@ discard block |
||
1047 | 1114 | date_default_timezone_set($globalTimezone); |
1048 | 1115 | $datetime = new DateTime(); |
1049 | 1116 | $offset = $datetime->format('P'); |
1050 | - } else $offset = '+00:00'; |
|
1117 | + } else { |
|
1118 | + $offset = '+00:00'; |
|
1119 | + } |
|
1051 | 1120 | |
1052 | 1121 | if ($globalDBdriver == 'mysql') { |
1053 | 1122 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1096,7 +1165,9 @@ discard block |
||
1096 | 1165 | date_default_timezone_set($globalTimezone); |
1097 | 1166 | $datetime = new DateTime(); |
1098 | 1167 | $offset = $datetime->format('P'); |
1099 | - } else $offset = '+00:00'; |
|
1168 | + } else { |
|
1169 | + $offset = '+00:00'; |
|
1170 | + } |
|
1100 | 1171 | $filter_query = $this->getFilter($filters,true,true); |
1101 | 1172 | if ($globalDBdriver == 'mysql') { |
1102 | 1173 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1145,7 +1216,9 @@ discard block |
||
1145 | 1216 | date_default_timezone_set($globalTimezone); |
1146 | 1217 | $datetime = new DateTime(); |
1147 | 1218 | $offset = $datetime->format('P'); |
1148 | - } else $offset = '+00:00'; |
|
1219 | + } else { |
|
1220 | + $offset = '+00:00'; |
|
1221 | + } |
|
1149 | 1222 | |
1150 | 1223 | $orderby_sql = ''; |
1151 | 1224 | if ($orderby == "hour") |
@@ -1214,7 +1287,9 @@ discard block |
||
1214 | 1287 | date_default_timezone_set($globalTimezone); |
1215 | 1288 | $datetime = new DateTime($date); |
1216 | 1289 | $offset = $datetime->format('P'); |
1217 | - } else $offset = '+00:00'; |
|
1290 | + } else { |
|
1291 | + $offset = '+00:00'; |
|
1292 | + } |
|
1218 | 1293 | |
1219 | 1294 | if ($globalDBdriver == 'mysql') { |
1220 | 1295 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1262,7 +1337,9 @@ discard block |
||
1262 | 1337 | date_default_timezone_set($globalTimezone); |
1263 | 1338 | $datetime = new DateTime(); |
1264 | 1339 | $offset = $datetime->format('P'); |
1265 | - } else $offset = '+00:00'; |
|
1340 | + } else { |
|
1341 | + $offset = '+00:00'; |
|
1342 | + } |
|
1266 | 1343 | |
1267 | 1344 | if ($globalDBdriver == 'mysql') { |
1268 | 1345 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1327,8 +1404,11 @@ discard block |
||
1327 | 1404 | $query_values = array_merge($query_values,array(':month' => $month)); |
1328 | 1405 | } |
1329 | 1406 | } |
1330 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1331 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1407 | + if (empty($query_values)) { |
|
1408 | + $queryi .= $this->getFilter($filters); |
|
1409 | + } else { |
|
1410 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1411 | + } |
|
1332 | 1412 | |
1333 | 1413 | $sth = $this->db->prepare($queryi); |
1334 | 1414 | $sth->execute($query_values); |
@@ -1365,8 +1445,11 @@ discard block |
||
1365 | 1445 | $query_values = array_merge($query_values,array(':month' => $month)); |
1366 | 1446 | } |
1367 | 1447 | } |
1368 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1369 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1448 | + if (empty($query_values)) { |
|
1449 | + $queryi .= $this->getFilter($filters); |
|
1450 | + } else { |
|
1451 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1452 | + } |
|
1370 | 1453 | |
1371 | 1454 | $sth = $this->db->prepare($queryi); |
1372 | 1455 | $sth->execute($query_values); |
@@ -1388,7 +1471,9 @@ discard block |
||
1388 | 1471 | date_default_timezone_set($globalTimezone); |
1389 | 1472 | $datetime = new DateTime(); |
1390 | 1473 | $offset = $datetime->format('P'); |
1391 | - } else $offset = '+00:00'; |
|
1474 | + } else { |
|
1475 | + $offset = '+00:00'; |
|
1476 | + } |
|
1392 | 1477 | |
1393 | 1478 | if ($globalDBdriver == 'mysql') { |
1394 | 1479 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1492,7 +1577,9 @@ discard block |
||
1492 | 1577 | */ |
1493 | 1578 | public function parseDirection($direction = 0) |
1494 | 1579 | { |
1495 | - if ($direction == '') $direction = 0; |
|
1580 | + if ($direction == '') { |
|
1581 | + $direction = 0; |
|
1582 | + } |
|
1496 | 1583 | $direction_array = array(); |
1497 | 1584 | $temp_array = array(); |
1498 | 1585 | |
@@ -1581,7 +1668,9 @@ discard block |
||
1581 | 1668 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1582 | 1669 | |
1583 | 1670 | $Connection = new Connection($this->db); |
1584 | - if (!$Connection->tableExists('countries')) return ''; |
|
1671 | + if (!$Connection->tableExists('countries')) { |
|
1672 | + return ''; |
|
1673 | + } |
|
1585 | 1674 | |
1586 | 1675 | try { |
1587 | 1676 | /* |
@@ -1601,9 +1690,13 @@ discard block |
||
1601 | 1690 | $sth->closeCursor(); |
1602 | 1691 | if (count($row) > 0) { |
1603 | 1692 | return $row; |
1604 | - } else return ''; |
|
1693 | + } else { |
|
1694 | + return ''; |
|
1695 | + } |
|
1605 | 1696 | } catch (PDOException $e) { |
1606 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1697 | + if (isset($globalDebug) && $globalDebug) { |
|
1698 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1699 | + } |
|
1607 | 1700 | return ''; |
1608 | 1701 | } |
1609 | 1702 | |
@@ -1621,7 +1714,9 @@ discard block |
||
1621 | 1714 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1622 | 1715 | |
1623 | 1716 | $Connection = new Connection($this->db); |
1624 | - if (!$Connection->tableExists('countries')) return ''; |
|
1717 | + if (!$Connection->tableExists('countries')) { |
|
1718 | + return ''; |
|
1719 | + } |
|
1625 | 1720 | |
1626 | 1721 | try { |
1627 | 1722 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1633,9 +1728,13 @@ discard block |
||
1633 | 1728 | $sth->closeCursor(); |
1634 | 1729 | if (count($row) > 0) { |
1635 | 1730 | return $row; |
1636 | - } else return ''; |
|
1731 | + } else { |
|
1732 | + return ''; |
|
1733 | + } |
|
1637 | 1734 | } catch (PDOException $e) { |
1638 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1735 | + if (isset($globalDebug) && $globalDebug) { |
|
1736 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1737 | + } |
|
1639 | 1738 | return ''; |
1640 | 1739 | } |
1641 | 1740 | |
@@ -1696,7 +1795,9 @@ discard block |
||
1696 | 1795 | } |
1697 | 1796 | } |
1698 | 1797 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1699 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1798 | + if ($limit) { |
|
1799 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1800 | + } |
|
1700 | 1801 | $sth = $this->db->prepare($query); |
1701 | 1802 | $sth->execute($query_values); |
1702 | 1803 | $tracker_array = array(); |
@@ -1733,7 +1834,9 @@ discard block |
||
1733 | 1834 | foreach ($q_array as $q_item){ |
1734 | 1835 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1735 | 1836 | $additional_query .= " AND ("; |
1736 | - if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
1837 | + if (is_int($q_item)) { |
|
1838 | + $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
1839 | + } |
|
1737 | 1840 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
1738 | 1841 | $additional_query .= ")"; |
1739 | 1842 | } |
@@ -1759,7 +1862,9 @@ discard block |
||
1759 | 1862 | date_default_timezone_set($globalTimezone); |
1760 | 1863 | $datetime = new DateTime(); |
1761 | 1864 | $offset = $datetime->format('P'); |
1762 | - } else $offset = '+00:00'; |
|
1865 | + } else { |
|
1866 | + $offset = '+00:00'; |
|
1867 | + } |
|
1763 | 1868 | if ($date_array[1] != "") |
1764 | 1869 | { |
1765 | 1870 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1786,8 +1891,12 @@ discard block |
||
1786 | 1891 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1787 | 1892 | { |
1788 | 1893 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1789 | - } else $limit_query = ""; |
|
1790 | - } else $limit_query = ""; |
|
1894 | + } else { |
|
1895 | + $limit_query = ""; |
|
1896 | + } |
|
1897 | + } else { |
|
1898 | + $limit_query = ""; |
|
1899 | + } |
|
1791 | 1900 | if ($sort != "") |
1792 | 1901 | { |
1793 | 1902 | $search_orderby_array = $this->getOrderBy(); |
@@ -1830,7 +1939,9 @@ discard block |
||
1830 | 1939 | { |
1831 | 1940 | global $globalBitlyAccessToken; |
1832 | 1941 | |
1833 | - if ($globalBitlyAccessToken == '') return $url; |
|
1942 | + if ($globalBitlyAccessToken == '') { |
|
1943 | + return $url; |
|
1944 | + } |
|
1834 | 1945 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1835 | 1946 | $ch = curl_init(); |
1836 | 1947 | curl_setopt($ch, CURLOPT_HEADER, 0); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | - * Executes the SQL statements to get the spotter information |
|
92 | - * |
|
93 | - * @param String $query the SQL query |
|
94 | - * @param Array $params parameter of the query |
|
95 | - * @param String $limitQuery the limit query |
|
96 | - * @return Array the spotter information |
|
97 | - * |
|
98 | - */ |
|
91 | + * Executes the SQL statements to get the spotter information |
|
92 | + * |
|
93 | + * @param String $query the SQL query |
|
94 | + * @param Array $params parameter of the query |
|
95 | + * @param String $limitQuery the limit query |
|
96 | + * @return Array the spotter information |
|
97 | + * |
|
98 | + */ |
|
99 | 99 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
100 | 100 | { |
101 | 101 | date_default_timezone_set('UTC'); |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets all the spotter information based on the latest data entry |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets all the spotter information based on the latest data entry |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
239 | 239 | { |
240 | 240 | global $global_marine_query; |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Gets all the spotter information based on the callsign |
|
287 | - * |
|
288 | - * @return Array the spotter information |
|
289 | - * |
|
290 | - */ |
|
286 | + * Gets all the spotter information based on the callsign |
|
287 | + * |
|
288 | + * @return Array the spotter information |
|
289 | + * |
|
290 | + */ |
|
291 | 291 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
292 | 292 | { |
293 | 293 | global $global_marine_query; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Gets all the marine information based on the type |
|
343 | - * |
|
344 | - * @return Array the marine information |
|
345 | - * |
|
346 | - */ |
|
342 | + * Gets all the marine information based on the type |
|
343 | + * |
|
344 | + * @return Array the marine information |
|
345 | + * |
|
346 | + */ |
|
347 | 347 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
348 | 348 | { |
349 | 349 | global $global_marine_query; |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
452 | - * Gets all the marine information based on the captain |
|
453 | - * |
|
454 | - * @return Array the marine information |
|
455 | - * |
|
456 | - */ |
|
452 | + * Gets all the marine information based on the captain |
|
453 | + * |
|
454 | + * @return Array the marine information |
|
455 | + * |
|
456 | + */ |
|
457 | 457 | public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array()) |
458 | 458 | { |
459 | 459 | global $global_marine_query; |
@@ -491,12 +491,12 @@ discard block |
||
491 | 491 | } |
492 | 492 | |
493 | 493 | /** |
494 | - * Gets all source name |
|
495 | - * |
|
496 | - * @param String type format of source |
|
497 | - * @return Array list of source name |
|
498 | - * |
|
499 | - */ |
|
494 | + * Gets all source name |
|
495 | + * |
|
496 | + * @param String type format of source |
|
497 | + * @return Array list of source name |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getAllSourceName($type = '',$filters = array()) |
501 | 501 | { |
502 | 502 | $filter_query = $this->getFilter($filters,true,true); |
@@ -526,11 +526,11 @@ discard block |
||
526 | 526 | |
527 | 527 | |
528 | 528 | /** |
529 | - * Gets a list of all idents/callsigns |
|
530 | - * |
|
531 | - * @return Array list of ident/callsign names |
|
532 | - * |
|
533 | - */ |
|
529 | + * Gets a list of all idents/callsigns |
|
530 | + * |
|
531 | + * @return Array list of ident/callsign names |
|
532 | + * |
|
533 | + */ |
|
534 | 534 | public function getAllIdents($filters = array()) |
535 | 535 | { |
536 | 536 | $filter_query = $this->getFilter($filters,true,true); |
@@ -554,11 +554,11 @@ discard block |
||
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
557 | - * Gets all info from a mmsi |
|
558 | - * |
|
559 | - * @return Array ident |
|
560 | - * |
|
561 | - */ |
|
557 | + * Gets all info from a mmsi |
|
558 | + * |
|
559 | + * @return Array ident |
|
560 | + * |
|
561 | + */ |
|
562 | 562 | public function getIdentity($mmsi) |
563 | 563 | { |
564 | 564 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
574 | - * Add identity |
|
575 | - * |
|
576 | - */ |
|
574 | + * Add identity |
|
575 | + * |
|
576 | + */ |
|
577 | 577 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
578 | 578 | { |
579 | 579 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
642 | - * Update ident tracker data |
|
643 | - * |
|
644 | - * @param String $fammarine_id the ID |
|
645 | - * @param String $ident the marine ident |
|
646 | - * @return String success or false |
|
647 | - * |
|
648 | - */ |
|
642 | + * Update ident tracker data |
|
643 | + * |
|
644 | + * @param String $fammarine_id the ID |
|
645 | + * @param String $ident the marine ident |
|
646 | + * @return String success or false |
|
647 | + * |
|
648 | + */ |
|
649 | 649 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
650 | 650 | { |
651 | 651 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
663 | - * Update arrival marine data |
|
664 | - * |
|
665 | - * @param String $fammarine_id the ID |
|
666 | - * @param String $arrival_code the marine ident |
|
667 | - * @return String success or false |
|
668 | - * |
|
669 | - */ |
|
663 | + * Update arrival marine data |
|
664 | + * |
|
665 | + * @param String $fammarine_id the ID |
|
666 | + * @param String $arrival_code the marine ident |
|
667 | + * @return String success or false |
|
668 | + * |
|
669 | + */ |
|
670 | 670 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
671 | 671 | { |
672 | 672 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -681,19 +681,19 @@ discard block |
||
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
684 | - * Update Status data |
|
685 | - * |
|
686 | - * @param String $fammarine_id the ID |
|
687 | - * @param String $status_id the marine status id |
|
688 | - * @param String $status the marine status |
|
689 | - * @return String success or false |
|
690 | - * |
|
691 | - */ |
|
684 | + * Update Status data |
|
685 | + * |
|
686 | + * @param String $fammarine_id the ID |
|
687 | + * @param String $status_id the marine status id |
|
688 | + * @param String $status the marine status |
|
689 | + * @return String success or false |
|
690 | + * |
|
691 | + */ |
|
692 | 692 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
693 | 693 | { |
694 | 694 | |
695 | 695 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
696 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
696 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
697 | 697 | |
698 | 698 | try { |
699 | 699 | $sth = $this->db->prepare($query); |
@@ -706,17 +706,17 @@ discard block |
||
706 | 706 | |
707 | 707 | } |
708 | 708 | /** |
709 | - * Update latest marine data |
|
710 | - * |
|
711 | - * @param String $fammarine_id the ID |
|
712 | - * @param String $ident the marine ident |
|
713 | - * @return String success or false |
|
714 | - * |
|
715 | - */ |
|
709 | + * Update latest marine data |
|
710 | + * |
|
711 | + * @param String $fammarine_id the ID |
|
712 | + * @param String $ident the marine ident |
|
713 | + * @return String success or false |
|
714 | + * |
|
715 | + */ |
|
716 | 716 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
717 | 717 | { |
718 | 718 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
719 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
719 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
720 | 720 | |
721 | 721 | try { |
722 | 722 | $sth = $this->db->prepare($query); |
@@ -730,30 +730,30 @@ discard block |
||
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
733 | - * Adds a new spotter data |
|
734 | - * |
|
735 | - * @param String $fammarine_id the ID |
|
736 | - * @param String $ident the marine ident |
|
737 | - * @param String $departure_airport_icao the departure airport |
|
738 | - * @param String $arrival_airport_icao the arrival airport |
|
739 | - * @param String $latitude latitude of flight |
|
740 | - * @param String $longitude latitude of flight |
|
741 | - * @param String $waypoints waypoints of flight |
|
742 | - * @param String $heading heading of flight |
|
743 | - * @param String $groundspeed speed of flight |
|
744 | - * @param String $date date of flight |
|
745 | - * @param String $departure_airport_time departure time of flight |
|
746 | - * @param String $arrival_airport_time arrival time of flight |
|
747 | - * @param String $squawk squawk code of flight |
|
748 | - * @param String $route_stop route stop of flight |
|
749 | - * @param String $highlight highlight or not |
|
750 | - * @param String $ModeS ModesS code of flight |
|
751 | - * @param String $registration registration code of flight |
|
752 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
753 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
754 | - * @param String $verticalrate vertival rate of flight |
|
755 | - * @return String success or false |
|
756 | - */ |
|
733 | + * Adds a new spotter data |
|
734 | + * |
|
735 | + * @param String $fammarine_id the ID |
|
736 | + * @param String $ident the marine ident |
|
737 | + * @param String $departure_airport_icao the departure airport |
|
738 | + * @param String $arrival_airport_icao the arrival airport |
|
739 | + * @param String $latitude latitude of flight |
|
740 | + * @param String $longitude latitude of flight |
|
741 | + * @param String $waypoints waypoints of flight |
|
742 | + * @param String $heading heading of flight |
|
743 | + * @param String $groundspeed speed of flight |
|
744 | + * @param String $date date of flight |
|
745 | + * @param String $departure_airport_time departure time of flight |
|
746 | + * @param String $arrival_airport_time arrival time of flight |
|
747 | + * @param String $squawk squawk code of flight |
|
748 | + * @param String $route_stop route stop of flight |
|
749 | + * @param String $highlight highlight or not |
|
750 | + * @param String $ModeS ModesS code of flight |
|
751 | + * @param String $registration registration code of flight |
|
752 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
753 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
754 | + * @param String $verticalrate vertival rate of flight |
|
755 | + * @return String success or false |
|
756 | + */ |
|
757 | 757 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
758 | 758 | { |
759 | 759 | global $globalURL, $globalMarineImageFetch; |
@@ -881,11 +881,11 @@ discard block |
||
881 | 881 | |
882 | 882 | |
883 | 883 | /** |
884 | - * Gets the aircraft ident within the last hour |
|
885 | - * |
|
886 | - * @return String the ident |
|
887 | - * |
|
888 | - */ |
|
884 | + * Gets the aircraft ident within the last hour |
|
885 | + * |
|
886 | + * @return String the ident |
|
887 | + * |
|
888 | + */ |
|
889 | 889 | public function getIdentFromLastHour($ident) |
890 | 890 | { |
891 | 891 | global $globalDBdriver, $globalTimezone; |
@@ -901,11 +901,11 @@ discard block |
||
901 | 901 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
902 | 902 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
903 | 903 | $query_data = array(':ident' => $ident); |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | 906 | $sth = $this->db->prepare($query); |
907 | 907 | $sth->execute($query_data); |
908 | - $ident_result=''; |
|
908 | + $ident_result=''; |
|
909 | 909 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
910 | 910 | { |
911 | 911 | $ident_result = $row['ident']; |
@@ -916,11 +916,11 @@ discard block |
||
916 | 916 | |
917 | 917 | |
918 | 918 | /** |
919 | - * Gets the aircraft data from the last 20 seconds |
|
920 | - * |
|
921 | - * @return Array the spotter data |
|
922 | - * |
|
923 | - */ |
|
919 | + * Gets the aircraft data from the last 20 seconds |
|
920 | + * |
|
921 | + * @return Array the spotter data |
|
922 | + * |
|
923 | + */ |
|
924 | 924 | public function getRealTimeData($q = '') |
925 | 925 | { |
926 | 926 | global $globalDBdriver; |
@@ -958,11 +958,11 @@ discard block |
||
958 | 958 | |
959 | 959 | |
960 | 960 | /** |
961 | - * Gets all number of flight over countries |
|
962 | - * |
|
963 | - * @return Array the airline country list |
|
964 | - * |
|
965 | - */ |
|
961 | + * Gets all number of flight over countries |
|
962 | + * |
|
963 | + * @return Array the airline country list |
|
964 | + * |
|
965 | + */ |
|
966 | 966 | |
967 | 967 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
968 | 968 | { |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | /** |
1038 | - * Gets all callsigns that have flown over |
|
1039 | - * |
|
1040 | - * @return Array the callsign list |
|
1041 | - * |
|
1042 | - */ |
|
1038 | + * Gets all callsigns that have flown over |
|
1039 | + * |
|
1040 | + * @return Array the callsign list |
|
1041 | + * |
|
1042 | + */ |
|
1043 | 1043 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
1044 | 1044 | { |
1045 | 1045 | global $globalDBdriver; |
@@ -1106,11 +1106,11 @@ discard block |
||
1106 | 1106 | |
1107 | 1107 | |
1108 | 1108 | /** |
1109 | - * Counts all dates |
|
1110 | - * |
|
1111 | - * @return Array the date list |
|
1112 | - * |
|
1113 | - */ |
|
1109 | + * Counts all dates |
|
1110 | + * |
|
1111 | + * @return Array the date list |
|
1112 | + * |
|
1113 | + */ |
|
1114 | 1114 | public function countAllDates($filters = array()) |
1115 | 1115 | { |
1116 | 1116 | global $globalTimezone, $globalDBdriver; |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | |
1157 | 1157 | |
1158 | 1158 | /** |
1159 | - * Counts all dates during the last 7 days |
|
1160 | - * |
|
1161 | - * @return Array the date list |
|
1162 | - * |
|
1163 | - */ |
|
1159 | + * Counts all dates during the last 7 days |
|
1160 | + * |
|
1161 | + * @return Array the date list |
|
1162 | + * |
|
1163 | + */ |
|
1164 | 1164 | public function countAllDatesLast7Days($filters = array()) |
1165 | 1165 | { |
1166 | 1166 | global $globalTimezone, $globalDBdriver; |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | $query .= " GROUP BY date_name |
1183 | 1183 | ORDER BY date_name ASC"; |
1184 | 1184 | $query_data = array(':offset' => $offset); |
1185 | - } |
|
1185 | + } |
|
1186 | 1186 | |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute($query_data); |
@@ -1202,11 +1202,11 @@ discard block |
||
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
1205 | - * Counts all dates during the last month |
|
1206 | - * |
|
1207 | - * @return Array the date list |
|
1208 | - * |
|
1209 | - */ |
|
1205 | + * Counts all dates during the last month |
|
1206 | + * |
|
1207 | + * @return Array the date list |
|
1208 | + * |
|
1209 | + */ |
|
1210 | 1210 | public function countAllDatesLastMonth($filters = array()) |
1211 | 1211 | { |
1212 | 1212 | global $globalTimezone, $globalDBdriver; |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | $query .= " GROUP BY date_name |
1229 | 1229 | ORDER BY date_name ASC"; |
1230 | 1230 | $query_data = array(':offset' => $offset); |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | |
1233 | 1233 | $sth = $this->db->prepare($query); |
1234 | 1234 | $sth->execute($query_data); |
@@ -1250,11 +1250,11 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | |
1252 | 1252 | /** |
1253 | - * Counts all month |
|
1254 | - * |
|
1255 | - * @return Array the month list |
|
1256 | - * |
|
1257 | - */ |
|
1253 | + * Counts all month |
|
1254 | + * |
|
1255 | + * @return Array the month list |
|
1256 | + * |
|
1257 | + */ |
|
1258 | 1258 | public function countAllMonths($filters = array()) |
1259 | 1259 | { |
1260 | 1260 | global $globalTimezone, $globalDBdriver; |
@@ -1299,11 +1299,11 @@ discard block |
||
1299 | 1299 | |
1300 | 1300 | |
1301 | 1301 | /** |
1302 | - * Counts all dates during the last year |
|
1303 | - * |
|
1304 | - * @return Array the date list |
|
1305 | - * |
|
1306 | - */ |
|
1302 | + * Counts all dates during the last year |
|
1303 | + * |
|
1304 | + * @return Array the date list |
|
1305 | + * |
|
1306 | + */ |
|
1307 | 1307 | public function countAllMonthsLastYear($filters) |
1308 | 1308 | { |
1309 | 1309 | global $globalTimezone, $globalDBdriver; |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | $query .= " GROUP BY year_name, month_name |
1326 | 1326 | ORDER BY year_name, month_name ASC"; |
1327 | 1327 | $query_data = array(':offset' => $offset); |
1328 | - } |
|
1328 | + } |
|
1329 | 1329 | |
1330 | 1330 | $sth = $this->db->prepare($query); |
1331 | 1331 | $sth->execute($query_data); |
@@ -1348,11 +1348,11 @@ discard block |
||
1348 | 1348 | |
1349 | 1349 | |
1350 | 1350 | /** |
1351 | - * Counts all hours |
|
1352 | - * |
|
1353 | - * @return Array the hour list |
|
1354 | - * |
|
1355 | - */ |
|
1351 | + * Counts all hours |
|
1352 | + * |
|
1353 | + * @return Array the hour list |
|
1354 | + * |
|
1355 | + */ |
|
1356 | 1356 | public function countAllHours($orderby,$filters = array()) |
1357 | 1357 | { |
1358 | 1358 | global $globalTimezone, $globalDBdriver; |
@@ -1415,11 +1415,11 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | |
1417 | 1417 | /** |
1418 | - * Counts all hours by date |
|
1419 | - * |
|
1420 | - * @return Array the hour list |
|
1421 | - * |
|
1422 | - */ |
|
1418 | + * Counts all hours by date |
|
1419 | + * |
|
1420 | + * @return Array the hour list |
|
1421 | + * |
|
1422 | + */ |
|
1423 | 1423 | public function countAllHoursByDate($date, $filters = array()) |
1424 | 1424 | { |
1425 | 1425 | global $globalTimezone, $globalDBdriver; |
@@ -1463,11 +1463,11 @@ discard block |
||
1463 | 1463 | |
1464 | 1464 | |
1465 | 1465 | /** |
1466 | - * Counts all hours by a ident/callsign |
|
1467 | - * |
|
1468 | - * @return Array the hour list |
|
1469 | - * |
|
1470 | - */ |
|
1466 | + * Counts all hours by a ident/callsign |
|
1467 | + * |
|
1468 | + * @return Array the hour list |
|
1469 | + * |
|
1470 | + */ |
|
1471 | 1471 | public function countAllHoursByIdent($ident, $filters = array()) |
1472 | 1472 | { |
1473 | 1473 | global $globalTimezone, $globalDBdriver; |
@@ -1512,11 +1512,11 @@ discard block |
||
1512 | 1512 | |
1513 | 1513 | |
1514 | 1514 | /** |
1515 | - * Counts all vessels |
|
1516 | - * |
|
1517 | - * @return Integer the number of vessels |
|
1518 | - * |
|
1519 | - */ |
|
1515 | + * Counts all vessels |
|
1516 | + * |
|
1517 | + * @return Integer the number of vessels |
|
1518 | + * |
|
1519 | + */ |
|
1520 | 1520 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1521 | 1521 | { |
1522 | 1522 | global $globalDBdriver; |
@@ -1551,11 +1551,11 @@ discard block |
||
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | /** |
1554 | - * Counts all vessel type |
|
1555 | - * |
|
1556 | - * @return Integer the number of vessels |
|
1557 | - * |
|
1558 | - */ |
|
1554 | + * Counts all vessel type |
|
1555 | + * |
|
1556 | + * @return Integer the number of vessels |
|
1557 | + * |
|
1558 | + */ |
|
1559 | 1559 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1560 | 1560 | { |
1561 | 1561 | global $globalDBdriver; |
@@ -1590,11 +1590,11 @@ discard block |
||
1590 | 1590 | |
1591 | 1591 | |
1592 | 1592 | /** |
1593 | - * Counts all hours of today |
|
1594 | - * |
|
1595 | - * @return Array the hour list |
|
1596 | - * |
|
1597 | - */ |
|
1593 | + * Counts all hours of today |
|
1594 | + * |
|
1595 | + * @return Array the hour list |
|
1596 | + * |
|
1597 | + */ |
|
1598 | 1598 | public function countAllHoursFromToday($filters = array()) |
1599 | 1599 | { |
1600 | 1600 | global $globalTimezone, $globalDBdriver; |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | |
1637 | - /** |
|
1638 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1639 | - * |
|
1640 | - * @return Integer the Barrie Spotter ID |
|
1637 | + /** |
|
1638 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1639 | + * |
|
1640 | + * @return Integer the Barrie Spotter ID |
|
1641 | 1641 | q * |
1642 | - */ |
|
1642 | + */ |
|
1643 | 1643 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1644 | 1644 | { |
1645 | 1645 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1660,13 +1660,13 @@ discard block |
||
1660 | 1660 | |
1661 | 1661 | |
1662 | 1662 | /** |
1663 | - * Parses a date string |
|
1664 | - * |
|
1665 | - * @param String $dateString the date string |
|
1666 | - * @param String $timezone the timezone of a user |
|
1667 | - * @return Array the time information |
|
1668 | - * |
|
1669 | - */ |
|
1663 | + * Parses a date string |
|
1664 | + * |
|
1665 | + * @param String $dateString the date string |
|
1666 | + * @param String $timezone the timezone of a user |
|
1667 | + * @return Array the time information |
|
1668 | + * |
|
1669 | + */ |
|
1670 | 1670 | public function parseDateString($dateString, $timezone = '') |
1671 | 1671 | { |
1672 | 1672 | $time_array = array(); |
@@ -1699,12 +1699,12 @@ discard block |
||
1699 | 1699 | } |
1700 | 1700 | |
1701 | 1701 | /** |
1702 | - * Parses the direction degrees to working |
|
1703 | - * |
|
1704 | - * @param Float $direction the direction in degrees |
|
1705 | - * @return Array the direction information |
|
1706 | - * |
|
1707 | - */ |
|
1702 | + * Parses the direction degrees to working |
|
1703 | + * |
|
1704 | + * @param Float $direction the direction in degrees |
|
1705 | + * @return Array the direction information |
|
1706 | + * |
|
1707 | + */ |
|
1708 | 1708 | public function parseDirection($direction = 0) |
1709 | 1709 | { |
1710 | 1710 | if ($direction == '') $direction = 0; |
@@ -1783,12 +1783,12 @@ discard block |
||
1783 | 1783 | |
1784 | 1784 | |
1785 | 1785 | /** |
1786 | - * Gets Country from latitude/longitude |
|
1787 | - * |
|
1788 | - * @param Float $latitude latitute of the flight |
|
1789 | - * @param Float $longitude longitute of the flight |
|
1790 | - * @return String the countrie |
|
1791 | - */ |
|
1786 | + * Gets Country from latitude/longitude |
|
1787 | + * |
|
1788 | + * @param Float $latitude latitute of the flight |
|
1789 | + * @param Float $longitude longitute of the flight |
|
1790 | + * @return String the countrie |
|
1791 | + */ |
|
1792 | 1792 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1793 | 1793 | { |
1794 | 1794 | global $globalDBdriver, $globalDebug; |
@@ -1825,11 +1825,11 @@ discard block |
||
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | /** |
1828 | - * Gets Country from iso2 |
|
1829 | - * |
|
1830 | - * @param String $iso2 ISO2 country code |
|
1831 | - * @return String the countrie |
|
1832 | - */ |
|
1828 | + * Gets Country from iso2 |
|
1829 | + * |
|
1830 | + * @param String $iso2 ISO2 country code |
|
1831 | + * @return String the countrie |
|
1832 | + */ |
|
1833 | 1833 | public function getCountryFromISO2($iso2) |
1834 | 1834 | { |
1835 | 1835 | global $globalDBdriver, $globalDebug; |
@@ -1858,12 +1858,12 @@ discard block |
||
1858 | 1858 | |
1859 | 1859 | |
1860 | 1860 | /** |
1861 | - * Gets the short url from bit.ly |
|
1862 | - * |
|
1863 | - * @param String $url the full url |
|
1864 | - * @return String the bit.ly url |
|
1865 | - * |
|
1866 | - */ |
|
1861 | + * Gets the short url from bit.ly |
|
1862 | + * |
|
1863 | + * @param String $url the full url |
|
1864 | + * @return String the bit.ly url |
|
1865 | + * |
|
1866 | + */ |
|
1867 | 1867 | public function getBitlyURL($url) |
1868 | 1868 | { |
1869 | 1869 | global $globalBitlyAccessToken; |
@@ -1890,11 +1890,11 @@ discard block |
||
1890 | 1890 | |
1891 | 1891 | |
1892 | 1892 | /** |
1893 | - * Gets all vessels types that have flown over |
|
1894 | - * |
|
1895 | - * @return Array the vessel type list |
|
1896 | - * |
|
1897 | - */ |
|
1893 | + * Gets all vessels types that have flown over |
|
1894 | + * |
|
1895 | + * @return Array the vessel type list |
|
1896 | + * |
|
1897 | + */ |
|
1898 | 1898 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1899 | 1899 | { |
1900 | 1900 | global $globalDBdriver; |
@@ -1960,11 +1960,11 @@ discard block |
||
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
1963 | - * Gets all the tracker information |
|
1964 | - * |
|
1965 | - * @return Array the tracker information |
|
1966 | - * |
|
1967 | - */ |
|
1963 | + * Gets all the tracker information |
|
1964 | + * |
|
1965 | + * @return Array the tracker information |
|
1966 | + * |
|
1967 | + */ |
|
1968 | 1968 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1969 | 1969 | { |
1970 | 1970 | global $globalTimezone, $globalDBdriver; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.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,7 +81,7 @@ discard block |
||
81 | 81 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
82 | 82 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
83 | 83 | if ($filter_query_where != '') { |
84 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
84 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
85 | 85 | } |
86 | 86 | $filter_query = $filter_query_join.$filter_query_where; |
87 | 87 | return $filter_query; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return Array the spotter information |
97 | 97 | * |
98 | 98 | */ |
99 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
99 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
100 | 100 | { |
101 | 101 | date_default_timezone_set('UTC'); |
102 | 102 | if (!is_string($query)) |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | $sth = $this->db->prepare($query.$limitQuery); |
117 | 117 | $sth->execute($params); |
118 | 118 | } catch (PDOException $e) { |
119 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
119 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
120 | 120 | exit(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $num_rows = 0; |
124 | 124 | $spotter_array = array(); |
125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
126 | 126 | { |
127 | 127 | $num_rows++; |
128 | 128 | $temp_array = array(); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | } |
162 | 162 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
163 | 163 | |
164 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
164 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
165 | 165 | { |
166 | 166 | $Image = new Image($this->db); |
167 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
167 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
168 | 168 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
169 | 169 | unset($Image); |
170 | 170 | if (count($image_array) > 0) { |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | { |
201 | 201 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
202 | 202 | } else { |
203 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
203 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
204 | 204 | } |
205 | 205 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
206 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
207 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
206 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
207 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
208 | 208 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
209 | 209 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
210 | 210 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
211 | 211 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
212 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
213 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
212 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
213 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
214 | 214 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
215 | 215 | } |
216 | 216 | } |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | if ($limit != "") |
244 | 244 | { |
245 | 245 | $limit_array = explode(",", $limit); |
246 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
247 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
246 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
247 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
248 | 248 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
249 | 249 | { |
250 | 250 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | } else { |
259 | 259 | $orderby_query = " ORDER BY marine_output.date DESC"; |
260 | 260 | } |
261 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
262 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
261 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
262 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
263 | 263 | return $spotter_array; |
264 | 264 | } |
265 | 265 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | if ($id == '') return array(); |
278 | 278 | $additional_query = "marine_output.fammarine_id = :id"; |
279 | 279 | $query_values = array(':id' => $id); |
280 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
281 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
280 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
281 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
282 | 282 | return $spotter_array; |
283 | 283 | } |
284 | 284 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $query_values = array(); |
298 | 298 | $limit_query = ''; |
299 | 299 | $additional_query = ''; |
300 | - $filter_query = $this->getFilter($filter,true,true); |
|
300 | + $filter_query = $this->getFilter($filter, true, true); |
|
301 | 301 | if ($ident != "") |
302 | 302 | { |
303 | 303 | if (!is_string($ident)) |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | { |
314 | 314 | $limit_array = explode(",", $limit); |
315 | 315 | |
316 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
317 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
316 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
317 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
318 | 318 | |
319 | 319 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
320 | 320 | { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $query_values = array(); |
354 | 354 | $limit_query = ''; |
355 | 355 | $additional_query = ''; |
356 | - $filter_query = $this->getFilter($filter,true,true); |
|
356 | + $filter_query = $this->getFilter($filter, true, true); |
|
357 | 357 | if (!is_string($type)) |
358 | 358 | { |
359 | 359 | return false; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | { |
367 | 367 | $limit_array = explode(",", $limit); |
368 | 368 | |
369 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
370 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
369 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
370 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
371 | 371 | |
372 | 372 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
373 | 373 | { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | return $spotter_array; |
392 | 392 | } |
393 | 393 | |
394 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
394 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
395 | 395 | { |
396 | 396 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
397 | 397 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $limit_query = ''; |
400 | 400 | $additional_query = ''; |
401 | 401 | |
402 | - $filter_query = $this->getFilter($filter,true,true); |
|
402 | + $filter_query = $this->getFilter($filter, true, true); |
|
403 | 403 | |
404 | 404 | if ($date != "") |
405 | 405 | { |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | { |
426 | 426 | $limit_array = explode(",", $limit); |
427 | 427 | |
428 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
429 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
428 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
429 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
430 | 430 | |
431 | 431 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
432 | 432 | { |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $query_values = array(); |
462 | 462 | $limit_query = ''; |
463 | 463 | $additional_query = ''; |
464 | - $filter_query = $this->getFilter($filter,true,true); |
|
464 | + $filter_query = $this->getFilter($filter, true, true); |
|
465 | 465 | if ($captain != "") |
466 | 466 | { |
467 | 467 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | if ($limit != "") |
471 | 471 | { |
472 | 472 | $limit_array = explode(",", $limit); |
473 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
474 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
473 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
474 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
475 | 475 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
476 | 476 | { |
477 | 477 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | * @return Array list of source name |
498 | 498 | * |
499 | 499 | */ |
500 | - public function getAllSourceName($type = '',$filters = array()) |
|
500 | + public function getAllSourceName($type = '', $filters = array()) |
|
501 | 501 | { |
502 | - $filter_query = $this->getFilter($filters,true,true); |
|
502 | + $filter_query = $this->getFilter($filters, true, true); |
|
503 | 503 | $query_values = array(); |
504 | - $query = "SELECT DISTINCT marine_output.source_name |
|
504 | + $query = "SELECT DISTINCT marine_output.source_name |
|
505 | 505 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
506 | 506 | if ($type != '') { |
507 | 507 | $query_values = array(':type' => $type); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $source_array = array(); |
517 | 517 | $temp_array = array(); |
518 | 518 | |
519 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
519 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
520 | 520 | { |
521 | 521 | $temp_array['source_name'] = $row['source_name']; |
522 | 522 | $source_array[] = $temp_array; |
@@ -533,8 +533,8 @@ discard block |
||
533 | 533 | */ |
534 | 534 | public function getAllIdents($filters = array()) |
535 | 535 | { |
536 | - $filter_query = $this->getFilter($filters,true,true); |
|
537 | - $query = "SELECT DISTINCT marine_output.ident |
|
536 | + $filter_query = $this->getFilter($filters, true, true); |
|
537 | + $query = "SELECT DISTINCT marine_output.ident |
|
538 | 538 | FROM marine_output".$filter_query." marine_output.ident <> '' |
539 | 539 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
540 | 540 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $ident_array = array(); |
545 | 545 | $temp_array = array(); |
546 | 546 | |
547 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
547 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
548 | 548 | { |
549 | 549 | $temp_array['ident'] = $row['ident']; |
550 | 550 | $ident_array[] = $temp_array; |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | */ |
562 | 562 | public function getIdentity($mmsi) |
563 | 563 | { |
564 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
564 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
565 | 565 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
566 | 566 | $sth = $this->db->prepare($query); |
567 | 567 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -574,23 +574,23 @@ discard block |
||
574 | 574 | * Add identity |
575 | 575 | * |
576 | 576 | */ |
577 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
577 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
578 | 578 | { |
579 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
579 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
580 | 580 | if ($mmsi != '') { |
581 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
582 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
583 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
584 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
581 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
582 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
583 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
584 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
585 | 585 | $identinfo = $this->getIdentity($mmsi); |
586 | 586 | if (empty($identinfo)) { |
587 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
587 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
588 | 588 | $sth = $this->db->prepare($query); |
589 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
589 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
590 | 590 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
591 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
591 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
592 | 592 | $sth = $this->db->prepare($query); |
593 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
593 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | } |
@@ -611,12 +611,12 @@ discard block |
||
611 | 611 | } else $offset = '+00:00'; |
612 | 612 | |
613 | 613 | if ($globalDBdriver == 'mysql') { |
614 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
614 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
615 | 615 | FROM marine_output |
616 | 616 | WHERE marine_output.date <> '' |
617 | 617 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
618 | 618 | } else { |
619 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
619 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
620 | 620 | FROM marine_output |
621 | 621 | WHERE marine_output.date <> '' |
622 | 622 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | $date_array = array(); |
629 | 629 | $temp_array = array(); |
630 | 630 | |
631 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
631 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
632 | 632 | { |
633 | 633 | $temp_array['date'] = $row['date']; |
634 | 634 | |
@@ -646,10 +646,10 @@ discard block |
||
646 | 646 | * @return String success or false |
647 | 647 | * |
648 | 648 | */ |
649 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
649 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
650 | 650 | { |
651 | 651 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
652 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
652 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
653 | 653 | try { |
654 | 654 | $sth = $this->db->prepare($query); |
655 | 655 | $sth->execute($query_values); |
@@ -667,10 +667,10 @@ discard block |
||
667 | 667 | * @return String success or false |
668 | 668 | * |
669 | 669 | */ |
670 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
670 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
671 | 671 | { |
672 | 672 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
673 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
673 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
674 | 674 | try { |
675 | 675 | $sth = $this->db->prepare($query); |
676 | 676 | $sth->execute($query_values); |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | * @return String success or false |
690 | 690 | * |
691 | 691 | */ |
692 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
692 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
693 | 693 | { |
694 | 694 | |
695 | 695 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
696 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
696 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
697 | 697 | |
698 | 698 | try { |
699 | 699 | $sth = $this->db->prepare($query); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
717 | 717 | { |
718 | 718 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
719 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
719 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
720 | 720 | |
721 | 721 | try { |
722 | 722 | $sth = $this->db->prepare($query); |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @param String $verticalrate vertival rate of flight |
755 | 755 | * @return String success or false |
756 | 756 | */ |
757 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
|
757 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '') |
|
758 | 758 | { |
759 | 759 | global $globalURL, $globalMarineImageFetch; |
760 | 760 | |
@@ -821,36 +821,36 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | |
824 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
824 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
825 | 825 | { |
826 | 826 | $date = date("Y-m-d H:i:s", time()); |
827 | 827 | } |
828 | 828 | |
829 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
830 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
831 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
832 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
833 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
834 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
835 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
836 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
837 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
838 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
839 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
841 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
842 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
843 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
844 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
845 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
846 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
847 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
848 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
829 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
830 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
831 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
832 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
833 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
834 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
835 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
836 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
837 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
838 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
839 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
841 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
842 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
843 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
844 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
845 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
846 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
847 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
848 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
849 | 849 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
850 | 850 | $Image = new Image($this->db); |
851 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
851 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
852 | 852 | if (!isset($image_array[0]['mmsi'])) { |
853 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
853 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
854 | 854 | } |
855 | 855 | unset($Image); |
856 | 856 | } |
@@ -863,10 +863,10 @@ discard block |
||
863 | 863 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
864 | 864 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
865 | 865 | if ($arrival_date == '') $arrival_date = NULL; |
866 | - $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,captain_id,captain_name,race_id,race_name) |
|
866 | + $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,captain_id,captain_name,race_id,race_name) |
|
867 | 867 | 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,:captain_id,:captain_name,:race_id,:race_name)"; |
868 | 868 | |
869 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':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); |
|
869 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':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); |
|
870 | 870 | try { |
871 | 871 | $sth = $this->db->prepare($query); |
872 | 872 | $sth->execute($query_values); |
@@ -890,13 +890,13 @@ discard block |
||
890 | 890 | { |
891 | 891 | global $globalDBdriver, $globalTimezone; |
892 | 892 | if ($globalDBdriver == 'mysql') { |
893 | - $query = "SELECT marine_output.ident FROM marine_output |
|
893 | + $query = "SELECT marine_output.ident FROM marine_output |
|
894 | 894 | WHERE marine_output.ident = :ident |
895 | 895 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
896 | 896 | AND marine_output.date < UTC_TIMESTAMP()"; |
897 | 897 | $query_data = array(':ident' => $ident); |
898 | 898 | } else { |
899 | - $query = "SELECT marine_output.ident FROM marine_output |
|
899 | + $query = "SELECT marine_output.ident FROM marine_output |
|
900 | 900 | WHERE marine_output.ident = :ident |
901 | 901 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
902 | 902 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | |
906 | 906 | $sth = $this->db->prepare($query); |
907 | 907 | $sth->execute($query_data); |
908 | - $ident_result=''; |
|
909 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
908 | + $ident_result = ''; |
|
909 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
910 | 910 | { |
911 | 911 | $ident_result = $row['ident']; |
912 | 912 | } |
@@ -932,8 +932,8 @@ discard block |
||
932 | 932 | return false; |
933 | 933 | } else { |
934 | 934 | $q_array = explode(" ", $q); |
935 | - foreach ($q_array as $q_item){ |
|
936 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
935 | + foreach ($q_array as $q_item) { |
|
936 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
937 | 937 | $additional_query .= " AND ("; |
938 | 938 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
939 | 939 | $additional_query .= ")"; |
@@ -941,11 +941,11 @@ discard block |
||
941 | 941 | } |
942 | 942 | } |
943 | 943 | if ($globalDBdriver == 'mysql') { |
944 | - $query = "SELECT marine_output.* FROM marine_output |
|
944 | + $query = "SELECT marine_output.* FROM marine_output |
|
945 | 945 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
946 | 946 | AND marine_output.date < UTC_TIMESTAMP()"; |
947 | 947 | } else { |
948 | - $query = "SELECT marine_output.* FROM marine_output |
|
948 | + $query = "SELECT marine_output.* FROM marine_output |
|
949 | 949 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
950 | 950 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
951 | 951 | } |
@@ -964,16 +964,16 @@ discard block |
||
964 | 964 | * |
965 | 965 | */ |
966 | 966 | |
967 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
967 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
968 | 968 | { |
969 | 969 | global $globalDBdriver, $globalArchive; |
970 | 970 | //$filter_query = $this->getFilter($filters,true,true); |
971 | - $Connection= new Connection($this->db); |
|
971 | + $Connection = new Connection($this->db); |
|
972 | 972 | if (!$Connection->tableExists('countries')) return array(); |
973 | 973 | require_once('class.SpotterLive.php'); |
974 | 974 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
975 | 975 | $MarineLive = new MarineLive($this->db); |
976 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
976 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
977 | 977 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
978 | 978 | if ($olderthanmonths > 0) { |
979 | 979 | if ($globalDBdriver == 'mysql') { |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | } else { |
994 | 994 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
995 | 995 | $MarineArchive = new MarineArchive($this->db); |
996 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
996 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
997 | 997 | $filter_query .= " over_country <> ''"; |
998 | 998 | if ($olderthanmonths > 0) { |
999 | 999 | if ($globalDBdriver == 'mysql') { |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | $flight_array = array(); |
1022 | 1022 | $temp_array = array(); |
1023 | 1023 | |
1024 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1024 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1025 | 1025 | { |
1026 | 1026 | $temp_array['marine_count'] = $row['nb']; |
1027 | 1027 | $temp_array['marine_country'] = $row['name']; |
@@ -1040,11 +1040,11 @@ discard block |
||
1040 | 1040 | * @return Array the callsign list |
1041 | 1041 | * |
1042 | 1042 | */ |
1043 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
1043 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1044 | 1044 | { |
1045 | 1045 | global $globalDBdriver; |
1046 | - $filter_query = $this->getFilter($filters,true,true); |
|
1047 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1046 | + $filter_query = $this->getFilter($filters, true, true); |
|
1047 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1048 | 1048 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1049 | 1049 | if ($olderthanmonths > 0) { |
1050 | 1050 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1058,28 +1058,28 @@ discard block |
||
1058 | 1058 | if ($year != '') { |
1059 | 1059 | if ($globalDBdriver == 'mysql') { |
1060 | 1060 | $query .= " AND YEAR(marine_output.date) = :year"; |
1061 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1061 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1062 | 1062 | } else { |
1063 | 1063 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1064 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1064 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | if ($month != '') { |
1068 | 1068 | if ($globalDBdriver == 'mysql') { |
1069 | 1069 | $query .= " AND MONTH(marine_output.date) = :month"; |
1070 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1070 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1071 | 1071 | } else { |
1072 | 1072 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1073 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1073 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1074 | 1074 | } |
1075 | 1075 | } |
1076 | 1076 | if ($day != '') { |
1077 | 1077 | if ($globalDBdriver == 'mysql') { |
1078 | 1078 | $query .= " AND DAY(marine_output.date) = :day"; |
1079 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1079 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1080 | 1080 | } else { |
1081 | 1081 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1082 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1082 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1083 | 1083 | } |
1084 | 1084 | } |
1085 | 1085 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $callsign_array = array(); |
1092 | 1092 | $temp_array = array(); |
1093 | 1093 | |
1094 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1094 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1095 | 1095 | { |
1096 | 1096 | $temp_array['callsign_icao'] = $row['ident']; |
1097 | 1097 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $date_array = array(); |
1144 | 1144 | $temp_array = array(); |
1145 | 1145 | |
1146 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1146 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | 1147 | { |
1148 | 1148 | $temp_array['date_name'] = $row['date_name']; |
1149 | 1149 | $temp_array['date_count'] = $row['date_count']; |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | $datetime = new DateTime(); |
1170 | 1170 | $offset = $datetime->format('P'); |
1171 | 1171 | } else $offset = '+00:00'; |
1172 | - $filter_query = $this->getFilter($filters,true,true); |
|
1172 | + $filter_query = $this->getFilter($filters, true, true); |
|
1173 | 1173 | if ($globalDBdriver == 'mysql') { |
1174 | 1174 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1175 | 1175 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | $date_array = array(); |
1191 | 1191 | $temp_array = array(); |
1192 | 1192 | |
1193 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1193 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1194 | 1194 | { |
1195 | 1195 | $temp_array['date_name'] = $row['date_name']; |
1196 | 1196 | $temp_array['date_count'] = $row['date_count']; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $datetime = new DateTime(); |
1216 | 1216 | $offset = $datetime->format('P'); |
1217 | 1217 | } else $offset = '+00:00'; |
1218 | - $filter_query = $this->getFilter($filters,true,true); |
|
1218 | + $filter_query = $this->getFilter($filters, true, true); |
|
1219 | 1219 | if ($globalDBdriver == 'mysql') { |
1220 | 1220 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1221 | 1221 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $date_array = array(); |
1237 | 1237 | $temp_array = array(); |
1238 | 1238 | |
1239 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1239 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1240 | 1240 | { |
1241 | 1241 | $temp_array['date_name'] = $row['date_name']; |
1242 | 1242 | $temp_array['date_count'] = $row['date_count']; |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | $date_array = array(); |
1284 | 1284 | $temp_array = array(); |
1285 | 1285 | |
1286 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1286 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1287 | 1287 | { |
1288 | 1288 | $temp_array['month_name'] = $row['month_name']; |
1289 | 1289 | $temp_array['year_name'] = $row['year_name']; |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | $datetime = new DateTime(); |
1313 | 1313 | $offset = $datetime->format('P'); |
1314 | 1314 | } else $offset = '+00:00'; |
1315 | - $filter_query = $this->getFilter($filters,true,true); |
|
1315 | + $filter_query = $this->getFilter($filters, true, true); |
|
1316 | 1316 | if ($globalDBdriver == 'mysql') { |
1317 | 1317 | $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 |
1318 | 1318 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | $date_array = array(); |
1334 | 1334 | $temp_array = array(); |
1335 | 1335 | |
1336 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1336 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1337 | 1337 | { |
1338 | 1338 | $temp_array['year_name'] = $row['year_name']; |
1339 | 1339 | $temp_array['month_name'] = $row['month_name']; |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | * @return Array the hour list |
1354 | 1354 | * |
1355 | 1355 | */ |
1356 | - public function countAllHours($orderby,$filters = array()) |
|
1356 | + public function countAllHours($orderby, $filters = array()) |
|
1357 | 1357 | { |
1358 | 1358 | global $globalTimezone, $globalDBdriver; |
1359 | 1359 | if ($globalTimezone != '') { |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $hour_array = array(); |
1402 | 1402 | $temp_array = array(); |
1403 | 1403 | |
1404 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1404 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1405 | 1405 | { |
1406 | 1406 | $temp_array['hour_name'] = $row['hour_name']; |
1407 | 1407 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1423,8 +1423,8 @@ discard block |
||
1423 | 1423 | public function countAllHoursByDate($date, $filters = array()) |
1424 | 1424 | { |
1425 | 1425 | global $globalTimezone, $globalDBdriver; |
1426 | - $filter_query = $this->getFilter($filters,true,true); |
|
1427 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1426 | + $filter_query = $this->getFilter($filters, true, true); |
|
1427 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1428 | 1428 | if ($globalTimezone != '') { |
1429 | 1429 | date_default_timezone_set($globalTimezone); |
1430 | 1430 | $datetime = new DateTime($date); |
@@ -1432,12 +1432,12 @@ discard block |
||
1432 | 1432 | } else $offset = '+00:00'; |
1433 | 1433 | |
1434 | 1434 | if ($globalDBdriver == 'mysql') { |
1435 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1435 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1436 | 1436 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1437 | 1437 | GROUP BY hour_name |
1438 | 1438 | ORDER BY hour_name ASC"; |
1439 | 1439 | } else { |
1440 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1440 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1441 | 1441 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1442 | 1442 | GROUP BY hour_name |
1443 | 1443 | ORDER BY hour_name ASC"; |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | $hour_array = array(); |
1450 | 1450 | $temp_array = array(); |
1451 | 1451 | |
1452 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1452 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1453 | 1453 | { |
1454 | 1454 | $temp_array['hour_name'] = $row['hour_name']; |
1455 | 1455 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1471,8 +1471,8 @@ discard block |
||
1471 | 1471 | public function countAllHoursByIdent($ident, $filters = array()) |
1472 | 1472 | { |
1473 | 1473 | global $globalTimezone, $globalDBdriver; |
1474 | - $filter_query = $this->getFilter($filters,true,true); |
|
1475 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1474 | + $filter_query = $this->getFilter($filters, true, true); |
|
1475 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1476 | 1476 | if ($globalTimezone != '') { |
1477 | 1477 | date_default_timezone_set($globalTimezone); |
1478 | 1478 | $datetime = new DateTime(); |
@@ -1480,12 +1480,12 @@ discard block |
||
1480 | 1480 | } else $offset = '+00:00'; |
1481 | 1481 | |
1482 | 1482 | if ($globalDBdriver == 'mysql') { |
1483 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1483 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1484 | 1484 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1485 | 1485 | GROUP BY hour_name |
1486 | 1486 | ORDER BY hour_name ASC"; |
1487 | 1487 | } else { |
1488 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1488 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1489 | 1489 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1490 | 1490 | GROUP BY hour_name |
1491 | 1491 | ORDER BY hour_name ASC"; |
@@ -1493,12 +1493,12 @@ discard block |
||
1493 | 1493 | |
1494 | 1494 | |
1495 | 1495 | $sth = $this->db->prepare($query); |
1496 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1496 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1497 | 1497 | |
1498 | 1498 | $hour_array = array(); |
1499 | 1499 | $temp_array = array(); |
1500 | 1500 | |
1501 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1501 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1502 | 1502 | { |
1503 | 1503 | $temp_array['hour_name'] = $row['hour_name']; |
1504 | 1504 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1517,33 +1517,33 @@ discard block |
||
1517 | 1517 | * @return Integer the number of vessels |
1518 | 1518 | * |
1519 | 1519 | */ |
1520 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1520 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1521 | 1521 | { |
1522 | 1522 | global $globalDBdriver; |
1523 | 1523 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1524 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1524 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1525 | 1525 | $query_values = array(); |
1526 | 1526 | $query = ''; |
1527 | 1527 | if ($year != '') { |
1528 | 1528 | if ($globalDBdriver == 'mysql') { |
1529 | 1529 | $query .= " AND YEAR(marine_output.date) = :year"; |
1530 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1530 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1531 | 1531 | } else { |
1532 | 1532 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1533 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1533 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | if ($month != '') { |
1537 | 1537 | if ($globalDBdriver == 'mysql') { |
1538 | 1538 | $query .= " AND MONTH(marine_output.date) = :month"; |
1539 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1539 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1540 | 1540 | } else { |
1541 | 1541 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1542 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1542 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1546 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1546 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1547 | 1547 | |
1548 | 1548 | $sth = $this->db->prepare($queryi); |
1549 | 1549 | $sth->execute($query_values); |
@@ -1556,32 +1556,32 @@ discard block |
||
1556 | 1556 | * @return Integer the number of vessels |
1557 | 1557 | * |
1558 | 1558 | */ |
1559 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1559 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1560 | 1560 | { |
1561 | 1561 | global $globalDBdriver; |
1562 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1562 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1563 | 1563 | $query_values = array(); |
1564 | 1564 | $query = ''; |
1565 | 1565 | if ($year != '') { |
1566 | 1566 | if ($globalDBdriver == 'mysql') { |
1567 | 1567 | $query .= " AND YEAR(marine_output.date) = :year"; |
1568 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1568 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1569 | 1569 | } else { |
1570 | 1570 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1571 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1571 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1572 | 1572 | } |
1573 | 1573 | } |
1574 | 1574 | if ($month != '') { |
1575 | 1575 | if ($globalDBdriver == 'mysql') { |
1576 | 1576 | $query .= " AND MONTH(marine_output.date) = :month"; |
1577 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1577 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1578 | 1578 | } else { |
1579 | 1579 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1580 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1580 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1581 | 1581 | } |
1582 | 1582 | } |
1583 | 1583 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1584 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1584 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1585 | 1585 | |
1586 | 1586 | $sth = $this->db->prepare($queryi); |
1587 | 1587 | $sth->execute($query_values); |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | public function countAllHoursFromToday($filters = array()) |
1599 | 1599 | { |
1600 | 1600 | global $globalTimezone, $globalDBdriver; |
1601 | - $filter_query = $this->getFilter($filters,true,true); |
|
1601 | + $filter_query = $this->getFilter($filters, true, true); |
|
1602 | 1602 | if ($globalTimezone != '') { |
1603 | 1603 | date_default_timezone_set($globalTimezone); |
1604 | 1604 | $datetime = new DateTime(); |
@@ -1606,12 +1606,12 @@ discard block |
||
1606 | 1606 | } else $offset = '+00:00'; |
1607 | 1607 | |
1608 | 1608 | if ($globalDBdriver == 'mysql') { |
1609 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1609 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1610 | 1610 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1611 | 1611 | GROUP BY hour_name |
1612 | 1612 | ORDER BY hour_name ASC"; |
1613 | 1613 | } else { |
1614 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1614 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1615 | 1615 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1616 | 1616 | GROUP BY hour_name |
1617 | 1617 | ORDER BY hour_name ASC"; |
@@ -1623,7 +1623,7 @@ discard block |
||
1623 | 1623 | $hour_array = array(); |
1624 | 1624 | $temp_array = array(); |
1625 | 1625 | |
1626 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1626 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1627 | 1627 | { |
1628 | 1628 | $temp_array['hour_name'] = $row['hour_name']; |
1629 | 1629 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1642,9 +1642,9 @@ discard block |
||
1642 | 1642 | */ |
1643 | 1643 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1644 | 1644 | { |
1645 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1645 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1646 | 1646 | |
1647 | - $query = "SELECT marine_output.marine_id |
|
1647 | + $query = "SELECT marine_output.marine_id |
|
1648 | 1648 | FROM marine_output |
1649 | 1649 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1650 | 1650 | |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | $sth = $this->db->prepare($query); |
1653 | 1653 | $sth->execute(); |
1654 | 1654 | |
1655 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1655 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1656 | 1656 | { |
1657 | 1657 | return $row['marine_id']; |
1658 | 1658 | } |
@@ -1677,23 +1677,23 @@ discard block |
||
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | $current_date = date("Y-m-d H:i:s"); |
1680 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1680 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1681 | 1681 | |
1682 | 1682 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1683 | 1683 | |
1684 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1684 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1685 | 1685 | $years = $time_array['years']; |
1686 | 1686 | |
1687 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1687 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1688 | 1688 | $months = $time_array['months']; |
1689 | 1689 | |
1690 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1690 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1691 | 1691 | $days = $time_array['days']; |
1692 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1692 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1693 | 1693 | $hours = $time_array['hours']; |
1694 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1694 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1695 | 1695 | $minutes = $time_array['minutes']; |
1696 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1696 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1697 | 1697 | |
1698 | 1698 | return $time_array; |
1699 | 1699 | } |
@@ -1716,63 +1716,63 @@ discard block |
||
1716 | 1716 | $temp_array['direction_degree'] = $direction; |
1717 | 1717 | $temp_array['direction_shortname'] = "N"; |
1718 | 1718 | $temp_array['direction_fullname'] = "North"; |
1719 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1719 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1720 | 1720 | $temp_array['direction_degree'] = $direction; |
1721 | 1721 | $temp_array['direction_shortname'] = "NNE"; |
1722 | 1722 | $temp_array['direction_fullname'] = "North-Northeast"; |
1723 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1723 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1724 | 1724 | $temp_array['direction_degree'] = $direction; |
1725 | 1725 | $temp_array['direction_shortname'] = "NE"; |
1726 | 1726 | $temp_array['direction_fullname'] = "Northeast"; |
1727 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1727 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1728 | 1728 | $temp_array['direction_degree'] = $direction; |
1729 | 1729 | $temp_array['direction_shortname'] = "ENE"; |
1730 | 1730 | $temp_array['direction_fullname'] = "East-Northeast"; |
1731 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1731 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1732 | 1732 | $temp_array['direction_degree'] = $direction; |
1733 | 1733 | $temp_array['direction_shortname'] = "E"; |
1734 | 1734 | $temp_array['direction_fullname'] = "East"; |
1735 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1735 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1736 | 1736 | $temp_array['direction_degree'] = $direction; |
1737 | 1737 | $temp_array['direction_shortname'] = "ESE"; |
1738 | 1738 | $temp_array['direction_fullname'] = "East-Southeast"; |
1739 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1739 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1740 | 1740 | $temp_array['direction_degree'] = $direction; |
1741 | 1741 | $temp_array['direction_shortname'] = "SE"; |
1742 | 1742 | $temp_array['direction_fullname'] = "Southeast"; |
1743 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1743 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1744 | 1744 | $temp_array['direction_degree'] = $direction; |
1745 | 1745 | $temp_array['direction_shortname'] = "SSE"; |
1746 | 1746 | $temp_array['direction_fullname'] = "South-Southeast"; |
1747 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1747 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1748 | 1748 | $temp_array['direction_degree'] = $direction; |
1749 | 1749 | $temp_array['direction_shortname'] = "S"; |
1750 | 1750 | $temp_array['direction_fullname'] = "South"; |
1751 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1751 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1752 | 1752 | $temp_array['direction_degree'] = $direction; |
1753 | 1753 | $temp_array['direction_shortname'] = "SSW"; |
1754 | 1754 | $temp_array['direction_fullname'] = "South-Southwest"; |
1755 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1755 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1756 | 1756 | $temp_array['direction_degree'] = $direction; |
1757 | 1757 | $temp_array['direction_shortname'] = "SW"; |
1758 | 1758 | $temp_array['direction_fullname'] = "Southwest"; |
1759 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1759 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1760 | 1760 | $temp_array['direction_degree'] = $direction; |
1761 | 1761 | $temp_array['direction_shortname'] = "WSW"; |
1762 | 1762 | $temp_array['direction_fullname'] = "West-Southwest"; |
1763 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1763 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1764 | 1764 | $temp_array['direction_degree'] = $direction; |
1765 | 1765 | $temp_array['direction_shortname'] = "W"; |
1766 | 1766 | $temp_array['direction_fullname'] = "West"; |
1767 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1767 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1768 | 1768 | $temp_array['direction_degree'] = $direction; |
1769 | 1769 | $temp_array['direction_shortname'] = "WNW"; |
1770 | 1770 | $temp_array['direction_fullname'] = "West-Northwest"; |
1771 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1771 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1772 | 1772 | $temp_array['direction_degree'] = $direction; |
1773 | 1773 | $temp_array['direction_shortname'] = "NW"; |
1774 | 1774 | $temp_array['direction_fullname'] = "Northwest"; |
1775 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1775 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1776 | 1776 | $temp_array['direction_degree'] = $direction; |
1777 | 1777 | $temp_array['direction_shortname'] = "NNW"; |
1778 | 1778 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1789,11 +1789,11 @@ discard block |
||
1789 | 1789 | * @param Float $longitude longitute of the flight |
1790 | 1790 | * @return String the countrie |
1791 | 1791 | */ |
1792 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1792 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1793 | 1793 | { |
1794 | 1794 | global $globalDBdriver, $globalDebug; |
1795 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1796 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1795 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1796 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1797 | 1797 | |
1798 | 1798 | $Connection = new Connection($this->db); |
1799 | 1799 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1833,7 +1833,7 @@ discard block |
||
1833 | 1833 | public function getCountryFromISO2($iso2) |
1834 | 1834 | { |
1835 | 1835 | global $globalDBdriver, $globalDebug; |
1836 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1836 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1837 | 1837 | |
1838 | 1838 | $Connection = new Connection($this->db); |
1839 | 1839 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1881,7 +1881,7 @@ discard block |
||
1881 | 1881 | |
1882 | 1882 | $bitly_data = json_decode($bitly_data); |
1883 | 1883 | $bitly_url = ''; |
1884 | - if ($bitly_data->status_txt = "OK"){ |
|
1884 | + if ($bitly_data->status_txt = "OK") { |
|
1885 | 1885 | $bitly_url = $bitly_data->data->url; |
1886 | 1886 | } |
1887 | 1887 | |
@@ -1895,11 +1895,11 @@ discard block |
||
1895 | 1895 | * @return Array the vessel type list |
1896 | 1896 | * |
1897 | 1897 | */ |
1898 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1898 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1899 | 1899 | { |
1900 | 1900 | global $globalDBdriver; |
1901 | - $filter_query = $this->getFilter($filters,true,true); |
|
1902 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1901 | + $filter_query = $this->getFilter($filters, true, true); |
|
1902 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1903 | 1903 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
1904 | 1904 | if ($olderthanmonths > 0) { |
1905 | 1905 | if ($globalDBdriver == 'mysql') { |
@@ -1919,28 +1919,28 @@ discard block |
||
1919 | 1919 | if ($year != '') { |
1920 | 1920 | if ($globalDBdriver == 'mysql') { |
1921 | 1921 | $query .= " AND YEAR(marine_output.date) = :year"; |
1922 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1922 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1923 | 1923 | } else { |
1924 | 1924 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1925 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1925 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1926 | 1926 | } |
1927 | 1927 | } |
1928 | 1928 | if ($month != '') { |
1929 | 1929 | if ($globalDBdriver == 'mysql') { |
1930 | 1930 | $query .= " AND MONTH(marine_output.date) = :month"; |
1931 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1931 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1932 | 1932 | } else { |
1933 | 1933 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1934 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1934 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1935 | 1935 | } |
1936 | 1936 | } |
1937 | 1937 | if ($day != '') { |
1938 | 1938 | if ($globalDBdriver == 'mysql') { |
1939 | 1939 | $query .= " AND DAY(marine_output.date) = :day"; |
1940 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1940 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1941 | 1941 | } else { |
1942 | 1942 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1943 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1943 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1944 | 1944 | } |
1945 | 1945 | } |
1946 | 1946 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | $sth->execute($query_values); |
1950 | 1950 | $marine_array = array(); |
1951 | 1951 | $temp_array = array(); |
1952 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1952 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1953 | 1953 | { |
1954 | 1954 | $temp_array['marine_type'] = $row['marine_type']; |
1955 | 1955 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -1965,13 +1965,13 @@ discard block |
||
1965 | 1965 | * @return Array the tracker information |
1966 | 1966 | * |
1967 | 1967 | */ |
1968 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1968 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1969 | 1969 | { |
1970 | 1970 | global $globalTimezone, $globalDBdriver; |
1971 | 1971 | date_default_timezone_set('UTC'); |
1972 | 1972 | $query_values = array(); |
1973 | 1973 | $additional_query = ''; |
1974 | - $filter_query = $this->getFilter($filters,true,true); |
|
1974 | + $filter_query = $this->getFilter($filters, true, true); |
|
1975 | 1975 | if ($q != "") |
1976 | 1976 | { |
1977 | 1977 | if (!is_string($q)) |
@@ -1979,8 +1979,8 @@ discard block |
||
1979 | 1979 | return false; |
1980 | 1980 | } else { |
1981 | 1981 | $q_array = explode(" ", $q); |
1982 | - foreach ($q_array as $q_item){ |
|
1983 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1982 | + foreach ($q_array as $q_item) { |
|
1983 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1984 | 1984 | $additional_query .= " AND ("; |
1985 | 1985 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
1986 | 1986 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1992,42 +1992,42 @@ discard block |
||
1992 | 1992 | } |
1993 | 1993 | if ($callsign != "") |
1994 | 1994 | { |
1995 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1995 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1996 | 1996 | if (!is_string($callsign)) |
1997 | 1997 | { |
1998 | 1998 | return false; |
1999 | 1999 | } else { |
2000 | 2000 | $additional_query .= " AND marine_output.ident = :callsign"; |
2001 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
2001 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
2002 | 2002 | } |
2003 | 2003 | } |
2004 | 2004 | if ($mmsi != "") |
2005 | 2005 | { |
2006 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
2006 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
2007 | 2007 | if (!is_numeric($mmsi)) |
2008 | 2008 | { |
2009 | 2009 | return false; |
2010 | 2010 | } else { |
2011 | 2011 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
2012 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
2012 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
2013 | 2013 | } |
2014 | 2014 | } |
2015 | 2015 | if ($imo != "") |
2016 | 2016 | { |
2017 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
2017 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
2018 | 2018 | if (!is_numeric($imo)) |
2019 | 2019 | { |
2020 | 2020 | return false; |
2021 | 2021 | } else { |
2022 | 2022 | $additional_query .= " AND marine_output.imo = :imo"; |
2023 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
2023 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
2024 | 2024 | } |
2025 | 2025 | } |
2026 | 2026 | if ($date_posted != "") |
2027 | 2027 | { |
2028 | 2028 | $date_array = explode(",", $date_posted); |
2029 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
2030 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
2029 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
2030 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
2031 | 2031 | if ($globalTimezone != '') { |
2032 | 2032 | date_default_timezone_set($globalTimezone); |
2033 | 2033 | $datetime = new DateTime(); |
@@ -2054,8 +2054,8 @@ discard block |
||
2054 | 2054 | if ($limit != "") |
2055 | 2055 | { |
2056 | 2056 | $limit_array = explode(",", $limit); |
2057 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2058 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2057 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2058 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2059 | 2059 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2060 | 2060 | { |
2061 | 2061 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2073,28 +2073,28 @@ discard block |
||
2073 | 2073 | } |
2074 | 2074 | } |
2075 | 2075 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2076 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2076 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2077 | 2077 | if ($globalDBdriver == 'mysql') { |
2078 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2078 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2079 | 2079 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2080 | 2080 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
2081 | 2081 | } else { |
2082 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2082 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2083 | 2083 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2084 | 2084 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
2085 | 2085 | } |
2086 | 2086 | } else { |
2087 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2087 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2088 | 2088 | ".$additional_query." |
2089 | 2089 | ".$orderby_query; |
2090 | 2090 | } |
2091 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2091 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2092 | 2092 | return $marine_array; |
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | public function getOrderBy() |
2096 | 2096 | { |
2097 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
2097 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
2098 | 2098 | |
2099 | 2099 | return $orderby; |
2100 | 2100 |
@@ -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) { |
@@ -78,8 +82,11 @@ discard block |
||
78 | 82 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
79 | 83 | } |
80 | 84 | } |
81 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
82 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
85 | + if ($filter_query_where == '' && $where) { |
|
86 | + $filter_query_where = ' WHERE'; |
|
87 | + } elseif ($filter_query_where != '' && $and) { |
|
88 | + $filter_query_where .= ' AND'; |
|
89 | + } |
|
83 | 90 | if ($filter_query_where != '') { |
84 | 91 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
85 | 92 | } |
@@ -133,39 +140,75 @@ discard block |
||
133 | 140 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
134 | 141 | } elseif (isset($row['spotter_archive_output_id'])) { |
135 | 142 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
136 | - */} |
|
137 | - elseif (isset($row['marineid'])) { |
|
143 | + */} elseif (isset($row['marineid'])) { |
|
138 | 144 | $temp_array['marine_id'] = $row['marineid']; |
139 | 145 | } else { |
140 | 146 | $temp_array['marine_id'] = ''; |
141 | 147 | } |
142 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
143 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
144 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
145 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
146 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
147 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
148 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
149 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
150 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
151 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
152 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
153 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
154 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
155 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
156 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
148 | + if (isset($row['fammarine_id'])) { |
|
149 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
150 | + } |
|
151 | + if (isset($row['mmsi'])) { |
|
152 | + $temp_array['mmsi'] = $row['mmsi']; |
|
153 | + } |
|
154 | + if (isset($row['type'])) { |
|
155 | + $temp_array['type'] = $row['type']; |
|
156 | + } |
|
157 | + if (isset($row['type_id'])) { |
|
158 | + $temp_array['type_id'] = $row['type_id']; |
|
159 | + } |
|
160 | + if (isset($row['status'])) { |
|
161 | + $temp_array['status'] = $row['status']; |
|
162 | + } |
|
163 | + if (isset($row['status_id'])) { |
|
164 | + $temp_array['status_id'] = $row['status_id']; |
|
165 | + } |
|
166 | + if (isset($row['captain_id'])) { |
|
167 | + $temp_array['captain_id'] = $row['captain_id']; |
|
168 | + } |
|
169 | + if (isset($row['captain_name'])) { |
|
170 | + $temp_array['captain_name'] = $row['captain_name']; |
|
171 | + } |
|
172 | + if (isset($row['race_id'])) { |
|
173 | + $temp_array['race_id'] = $row['race_id']; |
|
174 | + } |
|
175 | + if (isset($row['race_name'])) { |
|
176 | + $temp_array['race_name'] = $row['race_name']; |
|
177 | + } |
|
178 | + if (isset($row['ident'])) { |
|
179 | + $temp_array['ident'] = $row['ident']; |
|
180 | + } |
|
181 | + if (isset($row['arrival_port_name'])) { |
|
182 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
183 | + } |
|
184 | + if (isset($row['latitude'])) { |
|
185 | + $temp_array['latitude'] = $row['latitude']; |
|
186 | + } |
|
187 | + if (isset($row['longitude'])) { |
|
188 | + $temp_array['longitude'] = $row['longitude']; |
|
189 | + } |
|
190 | + if (isset($row['format_source'])) { |
|
191 | + $temp_array['format_source'] = $row['format_source']; |
|
192 | + } |
|
157 | 193 | if (isset($row['heading'])) { |
158 | 194 | $temp_array['heading'] = $row['heading']; |
159 | 195 | $heading_direction = $this->parseDirection($row['heading']); |
160 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
196 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
197 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
198 | + } |
|
199 | + } |
|
200 | + if (isset($row['ground_speed'])) { |
|
201 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
161 | 202 | } |
162 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
163 | 203 | |
164 | 204 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
165 | 205 | { |
166 | 206 | $Image = new Image($this->db); |
167 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
168 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
207 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
208 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
209 | + } else { |
|
210 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
211 | + } |
|
169 | 212 | unset($Image); |
170 | 213 | if (count($image_array) > 0) { |
171 | 214 | $temp_array['image'] = $image_array[0]['image']; |
@@ -217,13 +260,21 @@ discard block |
||
217 | 260 | } |
218 | 261 | |
219 | 262 | $fromsource = NULL; |
220 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
221 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
222 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
263 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
264 | + $temp_array['source_name'] = $row['source_name']; |
|
265 | + } |
|
266 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
267 | + $temp_array['over_country'] = $row['over_country']; |
|
268 | + } |
|
269 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
270 | + $temp_array['distance'] = $row['distance']; |
|
271 | + } |
|
223 | 272 | $temp_array['query_number_rows'] = $num_rows; |
224 | 273 | $spotter_array[] = $temp_array; |
225 | 274 | } |
226 | - if ($num_rows == 0) return array(); |
|
275 | + if ($num_rows == 0) { |
|
276 | + return array(); |
|
277 | + } |
|
227 | 278 | $spotter_array[0]['query_number_rows'] = $num_rows; |
228 | 279 | return $spotter_array; |
229 | 280 | } |
@@ -249,8 +300,12 @@ discard block |
||
249 | 300 | { |
250 | 301 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
251 | 302 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
252 | - } else $limit_query = ""; |
|
253 | - } else $limit_query = ""; |
|
303 | + } else { |
|
304 | + $limit_query = ""; |
|
305 | + } |
|
306 | + } else { |
|
307 | + $limit_query = ""; |
|
308 | + } |
|
254 | 309 | if ($sort != "") |
255 | 310 | { |
256 | 311 | $search_orderby_array = $this->getOrderBy(); |
@@ -274,7 +329,9 @@ discard block |
||
274 | 329 | global $global_marine_query; |
275 | 330 | |
276 | 331 | date_default_timezone_set('UTC'); |
277 | - if ($id == '') return array(); |
|
332 | + if ($id == '') { |
|
333 | + return array(); |
|
334 | + } |
|
278 | 335 | $additional_query = "marine_output.fammarine_id = :id"; |
279 | 336 | $query_values = array(':id' => $id); |
280 | 337 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -510,8 +567,11 @@ discard block |
||
510 | 567 | $query .= " ORDER BY marine_output.source_name ASC"; |
511 | 568 | |
512 | 569 | $sth = $this->db->prepare($query); |
513 | - if (!empty($query_values)) $sth->execute($query_values); |
|
514 | - else $sth->execute(); |
|
570 | + if (!empty($query_values)) { |
|
571 | + $sth->execute($query_values); |
|
572 | + } else { |
|
573 | + $sth->execute(); |
|
574 | + } |
|
515 | 575 | |
516 | 576 | $source_array = array(); |
517 | 577 | $temp_array = array(); |
@@ -566,8 +626,11 @@ discard block |
||
566 | 626 | $sth = $this->db->prepare($query); |
567 | 627 | $sth->execute(array(':mmsi' => $mmsi)); |
568 | 628 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | - if (isset($result[0])) return $result[0]; |
|
570 | - else return array(); |
|
629 | + if (isset($result[0])) { |
|
630 | + return $result[0]; |
|
631 | + } else { |
|
632 | + return array(); |
|
633 | + } |
|
571 | 634 | } |
572 | 635 | |
573 | 636 | /** |
@@ -608,7 +671,9 @@ discard block |
||
608 | 671 | date_default_timezone_set($globalTimezone); |
609 | 672 | $datetime = new DateTime(); |
610 | 673 | $offset = $datetime->format('P'); |
611 | - } else $offset = '+00:00'; |
|
674 | + } else { |
|
675 | + $offset = '+00:00'; |
|
676 | + } |
|
612 | 677 | |
613 | 678 | if ($globalDBdriver == 'mysql') { |
614 | 679 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -858,11 +923,19 @@ discard block |
||
858 | 923 | $latitude = 0; |
859 | 924 | $longitude = 0; |
860 | 925 | } |
861 | - if ($type_id == '') $type_id = NULL; |
|
862 | - if ($status_id == '') $status_id = NULL; |
|
863 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
926 | + if ($type_id == '') { |
|
927 | + $type_id = NULL; |
|
928 | + } |
|
929 | + if ($status_id == '') { |
|
930 | + $status_id = NULL; |
|
931 | + } |
|
932 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
933 | + $heading = 0; |
|
934 | + } |
|
864 | 935 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
865 | - if ($arrival_date == '') $arrival_date = NULL; |
|
936 | + if ($arrival_date == '') { |
|
937 | + $arrival_date = NULL; |
|
938 | + } |
|
866 | 939 | $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,captain_id,captain_name,race_id,race_name) |
867 | 940 | 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,:captain_id,:captain_name,:race_id,:race_name)"; |
868 | 941 | |
@@ -969,7 +1042,9 @@ discard block |
||
969 | 1042 | global $globalDBdriver, $globalArchive; |
970 | 1043 | //$filter_query = $this->getFilter($filters,true,true); |
971 | 1044 | $Connection= new Connection($this->db); |
972 | - if (!$Connection->tableExists('countries')) return array(); |
|
1045 | + if (!$Connection->tableExists('countries')) { |
|
1046 | + return array(); |
|
1047 | + } |
|
973 | 1048 | require_once('class.SpotterLive.php'); |
974 | 1049 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
975 | 1050 | $MarineLive = new MarineLive($this->db); |
@@ -1013,7 +1088,9 @@ discard block |
||
1013 | 1088 | $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 "; |
1014 | 1089 | } |
1015 | 1090 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
1016 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1091 | + if ($limit) { |
|
1092 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1093 | + } |
|
1017 | 1094 | |
1018 | 1095 | $sth = $this->db->prepare($query); |
1019 | 1096 | $sth->execute(); |
@@ -1047,12 +1124,18 @@ discard block |
||
1047 | 1124 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
1048 | 1125 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1049 | 1126 | if ($olderthanmonths > 0) { |
1050 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1051 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1127 | + if ($globalDBdriver == 'mysql') { |
|
1128 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1129 | + } else { |
|
1130 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1131 | + } |
|
1052 | 1132 | } |
1053 | 1133 | if ($sincedate != '') { |
1054 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1055 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1134 | + if ($globalDBdriver == 'mysql') { |
|
1135 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1136 | + } else { |
|
1137 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1138 | + } |
|
1056 | 1139 | } |
1057 | 1140 | $query_values = array(); |
1058 | 1141 | if ($year != '') { |
@@ -1083,7 +1166,9 @@ discard block |
||
1083 | 1166 | } |
1084 | 1167 | } |
1085 | 1168 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1086 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1169 | + if ($limit) { |
|
1170 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1171 | + } |
|
1087 | 1172 | |
1088 | 1173 | $sth = $this->db->prepare($query); |
1089 | 1174 | $sth->execute($query_values); |
@@ -1118,7 +1203,9 @@ discard block |
||
1118 | 1203 | date_default_timezone_set($globalTimezone); |
1119 | 1204 | $datetime = new DateTime(); |
1120 | 1205 | $offset = $datetime->format('P'); |
1121 | - } else $offset = '+00:00'; |
|
1206 | + } else { |
|
1207 | + $offset = '+00:00'; |
|
1208 | + } |
|
1122 | 1209 | |
1123 | 1210 | if ($globalDBdriver == 'mysql') { |
1124 | 1211 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1168,7 +1255,9 @@ discard block |
||
1168 | 1255 | date_default_timezone_set($globalTimezone); |
1169 | 1256 | $datetime = new DateTime(); |
1170 | 1257 | $offset = $datetime->format('P'); |
1171 | - } else $offset = '+00:00'; |
|
1258 | + } else { |
|
1259 | + $offset = '+00:00'; |
|
1260 | + } |
|
1172 | 1261 | $filter_query = $this->getFilter($filters,true,true); |
1173 | 1262 | if ($globalDBdriver == 'mysql') { |
1174 | 1263 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1214,7 +1303,9 @@ discard block |
||
1214 | 1303 | date_default_timezone_set($globalTimezone); |
1215 | 1304 | $datetime = new DateTime(); |
1216 | 1305 | $offset = $datetime->format('P'); |
1217 | - } else $offset = '+00:00'; |
|
1306 | + } else { |
|
1307 | + $offset = '+00:00'; |
|
1308 | + } |
|
1218 | 1309 | $filter_query = $this->getFilter($filters,true,true); |
1219 | 1310 | if ($globalDBdriver == 'mysql') { |
1220 | 1311 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1262,7 +1353,9 @@ discard block |
||
1262 | 1353 | date_default_timezone_set($globalTimezone); |
1263 | 1354 | $datetime = new DateTime(); |
1264 | 1355 | $offset = $datetime->format('P'); |
1265 | - } else $offset = '+00:00'; |
|
1356 | + } else { |
|
1357 | + $offset = '+00:00'; |
|
1358 | + } |
|
1266 | 1359 | |
1267 | 1360 | if ($globalDBdriver == 'mysql') { |
1268 | 1361 | $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 |
@@ -1311,7 +1404,9 @@ discard block |
||
1311 | 1404 | date_default_timezone_set($globalTimezone); |
1312 | 1405 | $datetime = new DateTime(); |
1313 | 1406 | $offset = $datetime->format('P'); |
1314 | - } else $offset = '+00:00'; |
|
1407 | + } else { |
|
1408 | + $offset = '+00:00'; |
|
1409 | + } |
|
1315 | 1410 | $filter_query = $this->getFilter($filters,true,true); |
1316 | 1411 | if ($globalDBdriver == 'mysql') { |
1317 | 1412 | $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 |
@@ -1360,7 +1455,9 @@ discard block |
||
1360 | 1455 | date_default_timezone_set($globalTimezone); |
1361 | 1456 | $datetime = new DateTime(); |
1362 | 1457 | $offset = $datetime->format('P'); |
1363 | - } else $offset = '+00:00'; |
|
1458 | + } else { |
|
1459 | + $offset = '+00:00'; |
|
1460 | + } |
|
1364 | 1461 | |
1365 | 1462 | $orderby_sql = ''; |
1366 | 1463 | if ($orderby == "hour") |
@@ -1429,7 +1526,9 @@ discard block |
||
1429 | 1526 | date_default_timezone_set($globalTimezone); |
1430 | 1527 | $datetime = new DateTime($date); |
1431 | 1528 | $offset = $datetime->format('P'); |
1432 | - } else $offset = '+00:00'; |
|
1529 | + } else { |
|
1530 | + $offset = '+00:00'; |
|
1531 | + } |
|
1433 | 1532 | |
1434 | 1533 | if ($globalDBdriver == 'mysql') { |
1435 | 1534 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1477,7 +1576,9 @@ discard block |
||
1477 | 1576 | date_default_timezone_set($globalTimezone); |
1478 | 1577 | $datetime = new DateTime(); |
1479 | 1578 | $offset = $datetime->format('P'); |
1480 | - } else $offset = '+00:00'; |
|
1579 | + } else { |
|
1580 | + $offset = '+00:00'; |
|
1581 | + } |
|
1481 | 1582 | |
1482 | 1583 | if ($globalDBdriver == 'mysql') { |
1483 | 1584 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1542,8 +1643,11 @@ discard block |
||
1542 | 1643 | $query_values = array_merge($query_values,array(':month' => $month)); |
1543 | 1644 | } |
1544 | 1645 | } |
1545 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1546 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1646 | + if (empty($query_values)) { |
|
1647 | + $queryi .= $this->getFilter($filters); |
|
1648 | + } else { |
|
1649 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1650 | + } |
|
1547 | 1651 | |
1548 | 1652 | $sth = $this->db->prepare($queryi); |
1549 | 1653 | $sth->execute($query_values); |
@@ -1580,8 +1684,11 @@ discard block |
||
1580 | 1684 | $query_values = array_merge($query_values,array(':month' => $month)); |
1581 | 1685 | } |
1582 | 1686 | } |
1583 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1584 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1687 | + if (empty($query_values)) { |
|
1688 | + $queryi .= $this->getFilter($filters); |
|
1689 | + } else { |
|
1690 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1691 | + } |
|
1585 | 1692 | |
1586 | 1693 | $sth = $this->db->prepare($queryi); |
1587 | 1694 | $sth->execute($query_values); |
@@ -1603,7 +1710,9 @@ discard block |
||
1603 | 1710 | date_default_timezone_set($globalTimezone); |
1604 | 1711 | $datetime = new DateTime(); |
1605 | 1712 | $offset = $datetime->format('P'); |
1606 | - } else $offset = '+00:00'; |
|
1713 | + } else { |
|
1714 | + $offset = '+00:00'; |
|
1715 | + } |
|
1607 | 1716 | |
1608 | 1717 | if ($globalDBdriver == 'mysql') { |
1609 | 1718 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1707,7 +1816,9 @@ discard block |
||
1707 | 1816 | */ |
1708 | 1817 | public function parseDirection($direction = 0) |
1709 | 1818 | { |
1710 | - if ($direction == '') $direction = 0; |
|
1819 | + if ($direction == '') { |
|
1820 | + $direction = 0; |
|
1821 | + } |
|
1711 | 1822 | $direction_array = array(); |
1712 | 1823 | $temp_array = array(); |
1713 | 1824 | |
@@ -1796,7 +1907,9 @@ discard block |
||
1796 | 1907 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1797 | 1908 | |
1798 | 1909 | $Connection = new Connection($this->db); |
1799 | - if (!$Connection->tableExists('countries')) return ''; |
|
1910 | + if (!$Connection->tableExists('countries')) { |
|
1911 | + return ''; |
|
1912 | + } |
|
1800 | 1913 | |
1801 | 1914 | try { |
1802 | 1915 | /* |
@@ -1816,9 +1929,13 @@ discard block |
||
1816 | 1929 | $sth->closeCursor(); |
1817 | 1930 | if (count($row) > 0) { |
1818 | 1931 | return $row; |
1819 | - } else return ''; |
|
1932 | + } else { |
|
1933 | + return ''; |
|
1934 | + } |
|
1820 | 1935 | } catch (PDOException $e) { |
1821 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1936 | + if (isset($globalDebug) && $globalDebug) { |
|
1937 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1938 | + } |
|
1822 | 1939 | return ''; |
1823 | 1940 | } |
1824 | 1941 | |
@@ -1836,7 +1953,9 @@ discard block |
||
1836 | 1953 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1837 | 1954 | |
1838 | 1955 | $Connection = new Connection($this->db); |
1839 | - if (!$Connection->tableExists('countries')) return ''; |
|
1956 | + if (!$Connection->tableExists('countries')) { |
|
1957 | + return ''; |
|
1958 | + } |
|
1840 | 1959 | |
1841 | 1960 | try { |
1842 | 1961 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1848,9 +1967,13 @@ discard block |
||
1848 | 1967 | $sth->closeCursor(); |
1849 | 1968 | if (count($row) > 0) { |
1850 | 1969 | return $row; |
1851 | - } else return ''; |
|
1970 | + } else { |
|
1971 | + return ''; |
|
1972 | + } |
|
1852 | 1973 | } catch (PDOException $e) { |
1853 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1974 | + if (isset($globalDebug) && $globalDebug) { |
|
1975 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1976 | + } |
|
1854 | 1977 | return ''; |
1855 | 1978 | } |
1856 | 1979 | |
@@ -1868,7 +1991,9 @@ discard block |
||
1868 | 1991 | { |
1869 | 1992 | global $globalBitlyAccessToken; |
1870 | 1993 | |
1871 | - if ($globalBitlyAccessToken == '') return $url; |
|
1994 | + if ($globalBitlyAccessToken == '') { |
|
1995 | + return $url; |
|
1996 | + } |
|
1872 | 1997 | |
1873 | 1998 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1874 | 1999 | |
@@ -1944,7 +2069,9 @@ discard block |
||
1944 | 2069 | } |
1945 | 2070 | } |
1946 | 2071 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
1947 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2072 | + if ($limit) { |
|
2073 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2074 | + } |
|
1948 | 2075 | $sth = $this->db->prepare($query); |
1949 | 2076 | $sth->execute($query_values); |
1950 | 2077 | $marine_array = array(); |
@@ -1982,9 +2109,15 @@ discard block |
||
1982 | 2109 | foreach ($q_array as $q_item){ |
1983 | 2110 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1984 | 2111 | $additional_query .= " AND ("; |
1985 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1986 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1987 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2112 | + if (is_int($q_item)) { |
|
2113 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2114 | + } |
|
2115 | + if (is_int($q_item)) { |
|
2116 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2117 | + } |
|
2118 | + if (is_int($q_item)) { |
|
2119 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2120 | + } |
|
1988 | 2121 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1989 | 2122 | $additional_query .= ")"; |
1990 | 2123 | } |
@@ -2032,7 +2165,9 @@ discard block |
||
2032 | 2165 | date_default_timezone_set($globalTimezone); |
2033 | 2166 | $datetime = new DateTime(); |
2034 | 2167 | $offset = $datetime->format('P'); |
2035 | - } else $offset = '+00:00'; |
|
2168 | + } else { |
|
2169 | + $offset = '+00:00'; |
|
2170 | + } |
|
2036 | 2171 | if ($date_array[1] != "") |
2037 | 2172 | { |
2038 | 2173 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2059,8 +2194,12 @@ discard block |
||
2059 | 2194 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2060 | 2195 | { |
2061 | 2196 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2062 | - } else $limit_query = ""; |
|
2063 | - } else $limit_query = ""; |
|
2197 | + } else { |
|
2198 | + $limit_query = ""; |
|
2199 | + } |
|
2200 | + } else { |
|
2201 | + $limit_query = ""; |
|
2202 | + } |
|
2064 | 2203 | if ($sort != "") |
2065 | 2204 | { |
2066 | 2205 | $search_orderby_array = $this->getOrderBy(); |