@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (isset($_GET['coord'])) |
13 | 13 | { |
14 | - $coords = explode(',',$_GET['coord']); |
|
14 | + $coords = explode(',', $_GET['coord']); |
|
15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
16 | 16 | } else { |
17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | |
23 | 23 | if (!empty($spotter_array)) |
24 | 24 | { |
25 | - foreach($spotter_array as $spotter_item) |
|
25 | + foreach ($spotter_array as $spotter_item) |
|
26 | 26 | { |
27 | 27 | date_default_timezone_set('UTC'); |
28 | 28 | //waypoint plotting |
29 | 29 | $output .= '{"type": "Feature",'; |
30 | 30 | $output .= '"properties": {'; |
31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $output .= '}'; |
60 | 60 | $output .= '},'; |
61 | 61 | } |
62 | - $output = substr($output, 0, -1); |
|
62 | + $output = substr($output, 0, -1); |
|
63 | 63 | } |
64 | 64 | $output .= ']}'; |
65 | 65 | print $output; |
@@ -13,62 +13,62 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | if (isset($filter[0]['source'])) { |
27 | - $filters = array_merge($filters,$filter); |
|
27 | + $filters = array_merge($filters, $filter); |
|
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | 70 | if ($filter['airlines'][0] != '') { |
71 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | 91 | $filter_query_date = ''; |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
112 | 112 | } |
113 | 113 | } |
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
118 | 118 | if ($filter_query_where != '') { |
119 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
119 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
126 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
127 | 127 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
128 | 128 | if ($over_country == '') { |
129 | 129 | $Spotter = new Spotter($this->db); |
130 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
130 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
131 | 131 | if (!empty($data_country)) $country = $data_country['iso2']; |
132 | 132 | else $country = ''; |
133 | 133 | } else $country = $over_country; |
134 | - if ($airline_type === NULL) $airline_type =''; |
|
134 | + if ($airline_type === NULL) $airline_type = ''; |
|
135 | 135 | |
136 | 136 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
137 | 137 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
138 | 138 | |
139 | 139 | // Route is not added in spotter_archive |
140 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
140 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
141 | 141 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
142 | 142 | |
143 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
143 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
144 | 144 | try { |
145 | 145 | $sth = $this->db->prepare($query); |
146 | 146 | $sth->execute($query_values); |
147 | 147 | $sth->closeCursor(); |
148 | - } catch(PDOException $e) { |
|
148 | + } catch (PDOException $e) { |
|
149 | 149 | return "error : ".$e->getMessage(); |
150 | 150 | } |
151 | 151 | return "success"; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | |
166 | 166 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
167 | 167 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
169 | 169 | |
170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
171 | 171 | |
172 | 172 | return $spotter_array; |
173 | 173 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
187 | 187 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
188 | 188 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
190 | 190 | |
191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
192 | 192 | /* |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
201 | 201 | */ |
202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
203 | 203 | |
204 | 204 | return $spotter_array; |
205 | 205 | } |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | { |
215 | 215 | date_default_timezone_set('UTC'); |
216 | 216 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
218 | 218 | |
219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
220 | 220 | |
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | 223 | $sth->execute(array(':id' => $id)); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo $e->getMessage(); |
226 | 226 | die; |
227 | 227 | } |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | { |
241 | 241 | date_default_timezone_set('UTC'); |
242 | 242 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
244 | 244 | |
245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
246 | 246 | |
247 | 247 | try { |
248 | 248 | $sth = $this->db->prepare($query); |
249 | 249 | $sth->execute(array(':id' => $id)); |
250 | - } catch(PDOException $e) { |
|
250 | + } catch (PDOException $e) { |
|
251 | 251 | echo $e->getMessage(); |
252 | 252 | die; |
253 | 253 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | date_default_timezone_set('UTC'); |
270 | 270 | |
271 | 271 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
273 | 273 | |
274 | 274 | try { |
275 | 275 | $sth = $this->db->prepare($query); |
276 | 276 | $sth->execute(array(':ident' => $ident)); |
277 | - } catch(PDOException $e) { |
|
277 | + } catch (PDOException $e) { |
|
278 | 278 | echo $e->getMessage(); |
279 | 279 | die; |
280 | 280 | } |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | date_default_timezone_set('UTC'); |
296 | 296 | |
297 | 297 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
299 | 299 | |
300 | 300 | try { |
301 | 301 | $sth = $this->db->prepare($query); |
302 | 302 | $sth->execute(array(':id' => $id)); |
303 | - } catch(PDOException $e) { |
|
303 | + } catch (PDOException $e) { |
|
304 | 304 | echo $e->getMessage(); |
305 | 305 | die; |
306 | 306 | } |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | date_default_timezone_set('UTC'); |
322 | 322 | |
323 | 323 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | 325 | |
326 | 326 | try { |
327 | 327 | $sth = $this->db->prepare($query); |
328 | 328 | $sth->execute(array(':id' => $id)); |
329 | - } catch(PDOException $e) { |
|
329 | + } catch (PDOException $e) { |
|
330 | 330 | echo $e->getMessage(); |
331 | 331 | die; |
332 | 332 | } |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | date_default_timezone_set('UTC'); |
349 | 349 | |
350 | 350 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
353 | 353 | |
354 | 354 | try { |
355 | 355 | $sth = $this->db->prepare($query); |
356 | 356 | $sth->execute(array(':ident' => $ident)); |
357 | - } catch(PDOException $e) { |
|
357 | + } catch (PDOException $e) { |
|
358 | 358 | echo $e->getMessage(); |
359 | 359 | die; |
360 | 360 | } |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * @return Array the spotter information |
372 | 372 | * |
373 | 373 | */ |
374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
374 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
375 | 375 | { |
376 | 376 | $Spotter = new Spotter($this->db); |
377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
379 | 379 | |
380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
381 | 381 | |
382 | 382 | return $spotter_array; |
383 | 383 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | try { |
391 | 391 | $sth = $this->db->prepare($query); |
392 | 392 | $sth->execute(); |
393 | - } catch(PDOException $e) { |
|
393 | + } catch (PDOException $e) { |
|
394 | 394 | echo $e->getMessage(); |
395 | 395 | die; |
396 | 396 | } |
@@ -402,24 +402,24 @@ discard block |
||
402 | 402 | * @return Array the spotter information |
403 | 403 | * |
404 | 404 | */ |
405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
405 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
406 | 406 | { |
407 | 407 | global $globalDBdriver, $globalLiveInterval; |
408 | 408 | date_default_timezone_set('UTC'); |
409 | 409 | |
410 | 410 | $filter_query = ''; |
411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
413 | 413 | } |
414 | 414 | // Use spotter_output also ? |
415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | 417 | } |
418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
419 | 419 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
420 | 420 | } |
421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
438 | 438 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
439 | 439 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
440 | 440 | */ |
441 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
441 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
442 | 442 | FROM spotter_archive |
443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
446 | 446 | } else { |
447 | 447 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
449 | 449 | FROM spotter_archive |
450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | try { |
456 | 456 | $sth = $this->db->prepare($query); |
457 | 457 | $sth->execute(); |
458 | - } catch(PDOException $e) { |
|
458 | + } catch (PDOException $e) { |
|
459 | 459 | echo $e->getMessage(); |
460 | 460 | die; |
461 | 461 | } |
@@ -470,24 +470,24 @@ discard block |
||
470 | 470 | * @return Array the spotter information |
471 | 471 | * |
472 | 472 | */ |
473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
473 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
474 | 474 | { |
475 | 475 | global $globalDBdriver, $globalLiveInterval; |
476 | 476 | date_default_timezone_set('UTC'); |
477 | 477 | |
478 | 478 | $filter_query = ''; |
479 | 479 | if (isset($filter['source']) && !empty($filter['source'])) { |
480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
480 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
481 | 481 | } |
482 | 482 | // Should use spotter_output also ? |
483 | 483 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | 485 | } |
486 | 486 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
487 | 487 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
488 | 488 | } |
489 | 489 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | FROM spotter_archive |
498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
499 | 499 | */ |
500 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
500 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
501 | 501 | FROM spotter_archive_output |
502 | 502 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
514 | 514 | */ |
515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
516 | 516 | FROM spotter_archive_output |
517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
526 | 526 | $sth->execute(); |
527 | - } catch(PDOException $e) { |
|
527 | + } catch (PDOException $e) { |
|
528 | 528 | echo $e->getMessage(); |
529 | 529 | die; |
530 | 530 | } |
@@ -539,23 +539,23 @@ discard block |
||
539 | 539 | * @return Array the spotter information |
540 | 540 | * |
541 | 541 | */ |
542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
542 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
543 | 543 | { |
544 | 544 | global $globalDBdriver, $globalLiveInterval; |
545 | 545 | date_default_timezone_set('UTC'); |
546 | 546 | |
547 | 547 | $filter_query = ''; |
548 | 548 | if (isset($filter['source']) && !empty($filter['source'])) { |
549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
549 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
550 | 550 | } |
551 | 551 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | 553 | } |
554 | 554 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
555 | 555 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
556 | 556 | } |
557 | 557 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | try { |
571 | 571 | $sth = $this->db->prepare($query); |
572 | 572 | $sth->execute(); |
573 | - } catch(PDOException $e) { |
|
573 | + } catch (PDOException $e) { |
|
574 | 574 | echo $e->getMessage(); |
575 | 575 | die; |
576 | 576 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return Array the spotter information |
591 | 591 | * |
592 | 592 | */ |
593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
594 | 594 | { |
595 | 595 | global $globalTimezone, $globalDBdriver; |
596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | $q_array = explode(" ", $q); |
614 | 614 | |
615 | - foreach ($q_array as $q_item){ |
|
615 | + foreach ($q_array as $q_item) { |
|
616 | 616 | $additional_query .= " AND ("; |
617 | 617 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
618 | 618 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($registration != "") |
646 | 646 | { |
647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
647 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($registration)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($aircraft_icao != "") |
657 | 657 | { |
658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
658 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($aircraft_icao)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($aircraft_manufacturer != "") |
668 | 668 | { |
669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($aircraft_manufacturer)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | |
688 | 688 | if ($airline_icao != "") |
689 | 689 | { |
690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
690 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
691 | 691 | if (!is_string($airline_icao)) |
692 | 692 | { |
693 | 693 | return false; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if ($airline_country != "") |
700 | 700 | { |
701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
701 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
702 | 702 | if (!is_string($airline_country)) |
703 | 703 | { |
704 | 704 | return false; |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | |
710 | 710 | if ($airline_type != "") |
711 | 711 | { |
712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
712 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
713 | 713 | if (!is_string($airline_type)) |
714 | 714 | { |
715 | 715 | return false; |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | |
732 | 732 | if ($airport != "") |
733 | 733 | { |
734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
734 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
735 | 735 | if (!is_string($airport)) |
736 | 736 | { |
737 | 737 | return false; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | if ($airport_country != "") |
744 | 744 | { |
745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
745 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
746 | 746 | if (!is_string($airport_country)) |
747 | 747 | { |
748 | 748 | return false; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | |
754 | 754 | if ($callsign != "") |
755 | 755 | { |
756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
756 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
757 | 757 | if (!is_string($callsign)) |
758 | 758 | { |
759 | 759 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $translate = $Translation->ident2icao($callsign); |
762 | 762 | if ($translate != $callsign) { |
763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
764 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
764 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
765 | 765 | } else { |
766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
767 | 767 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | if ($owner != "") |
772 | 772 | { |
773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
773 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
774 | 774 | if (!is_string($owner)) |
775 | 775 | { |
776 | 776 | return false; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | |
782 | 782 | if ($pilot_name != "") |
783 | 783 | { |
784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
784 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
785 | 785 | if (!is_string($pilot_name)) |
786 | 786 | { |
787 | 787 | return false; |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | |
793 | 793 | if ($pilot_id != "") |
794 | 794 | { |
795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
795 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
796 | 796 | if (!is_string($pilot_id)) |
797 | 797 | { |
798 | 798 | return false; |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | if ($departure_airport_route != "") |
805 | 805 | { |
806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
806 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
807 | 807 | if (!is_string($departure_airport_route)) |
808 | 808 | { |
809 | 809 | return false; |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | if ($arrival_airport_route != "") |
816 | 816 | { |
817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
817 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
818 | 818 | if (!is_string($arrival_airport_route)) |
819 | 819 | { |
820 | 820 | return false; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | { |
828 | 828 | $altitude_array = explode(",", $altitude); |
829 | 829 | |
830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
831 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
832 | 832 | |
833 | 833 | |
834 | 834 | if ($altitude_array[1] != "") |
@@ -846,8 +846,8 @@ discard block |
||
846 | 846 | { |
847 | 847 | $date_array = explode(",", $date_posted); |
848 | 848 | |
849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
849 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
850 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
851 | 851 | |
852 | 852 | if ($globalTimezone != '') { |
853 | 853 | date_default_timezone_set($globalTimezone); |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | { |
880 | 880 | $limit_array = explode(",", $limit); |
881 | 881 | |
882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
883 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
884 | 884 | |
885 | 885 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
886 | 886 | { |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | |
892 | 892 | |
893 | 893 | if ($origLat != "" && $origLon != "" && $dist != "") { |
894 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
895 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
894 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
895 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
896 | 896 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
897 | 897 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
898 | 898 | } else { |
@@ -909,12 +909,12 @@ discard block |
||
909 | 909 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
910 | 910 | } |
911 | 911 | |
912 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
912 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
913 | 913 | WHERE spotter_archive_output.ident <> '' |
914 | 914 | ".$additional_query." |
915 | 915 | ".$filter_query.$orderby_query; |
916 | 916 | } |
917 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
917 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
918 | 918 | |
919 | 919 | return $spotter_array; |
920 | 920 | } |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | try { |
932 | 932 | $sth = $this->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error"; |
936 | 936 | } |
937 | 937 | } |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | { |
969 | 969 | $limit_array = explode(",", $limit); |
970 | 970 | |
971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
972 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
973 | 973 | |
974 | 974 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
975 | 975 | { |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $query_values = array(); |
1011 | 1011 | $limit_query = ''; |
1012 | 1012 | $additional_query = ''; |
1013 | - $filter_query = $this->getFilter($filter,true,true); |
|
1013 | + $filter_query = $this->getFilter($filter, true, true); |
|
1014 | 1014 | |
1015 | 1015 | if ($owner != "") |
1016 | 1016 | { |
@@ -1027,8 +1027,8 @@ discard block |
||
1027 | 1027 | { |
1028 | 1028 | $limit_array = explode(",", $limit); |
1029 | 1029 | |
1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1032 | 1032 | |
1033 | 1033 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1034 | 1034 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | $query_values = array(); |
1069 | 1069 | $limit_query = ''; |
1070 | 1070 | $additional_query = ''; |
1071 | - $filter_query = $this->getFilter($filter,true,true); |
|
1071 | + $filter_query = $this->getFilter($filter, true, true); |
|
1072 | 1072 | |
1073 | 1073 | if ($pilot != "") |
1074 | 1074 | { |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | { |
1081 | 1081 | $limit_array = explode(",", $limit); |
1082 | 1082 | |
1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1085 | 1085 | |
1086 | 1086 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1087 | 1087 | { |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @return Array the airline country list |
1112 | 1112 | * |
1113 | 1113 | */ |
1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1114 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1115 | 1115 | { |
1116 | 1116 | global $globalDBdriver; |
1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $flight_array = array(); |
1141 | 1141 | $temp_array = array(); |
1142 | 1142 | |
1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1144 | 1144 | { |
1145 | 1145 | $temp_array['flight_count'] = $row['nb']; |
1146 | 1146 | $temp_array['flight_country'] = $row['name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @return Array the airline country list |
1158 | 1158 | * |
1159 | 1159 | */ |
1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1160 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1161 | 1161 | { |
1162 | 1162 | global $globalDBdriver; |
1163 | 1163 | /* |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $flight_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['airline_icao'] = $row['airline_icao']; |
1192 | 1192 | $temp_array['flight_count'] = $row['nb']; |
@@ -1204,14 +1204,14 @@ discard block |
||
1204 | 1204 | * @return Array the spotter information |
1205 | 1205 | * |
1206 | 1206 | */ |
1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1207 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1208 | 1208 | { |
1209 | 1209 | $Spotter = new Spotter($this->db); |
1210 | 1210 | date_default_timezone_set('UTC'); |
1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1212 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1213 | - $date = date('c',$date); |
|
1214 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1212 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1213 | + $date = date('c', $date); |
|
1214 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1215 | 1215 | return $spotter_array; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1221,14 +1221,14 @@ discard block |
||
1221 | 1221 | * @return Array the spotter information |
1222 | 1222 | * |
1223 | 1223 | */ |
1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1224 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1225 | 1225 | { |
1226 | 1226 | $Spotter = new Spotter($this->db); |
1227 | 1227 | date_default_timezone_set('UTC'); |
1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1229 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1230 | - $date = date('c',$date); |
|
1231 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1229 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1230 | + $date = date('c', $date); |
|
1231 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1232 | 1232 | return $spotter_array; |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * @return Array the spotter information |
1239 | 1239 | * |
1240 | 1240 | */ |
1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1242 | 1242 | { |
1243 | 1243 | global $global_query; |
1244 | 1244 | $Spotter = new Spotter(); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | $query_values = array(); |
1247 | 1247 | $limit_query = ''; |
1248 | 1248 | $additional_query = ''; |
1249 | - $filter_query = $this->getFilter($filters,true,true); |
|
1249 | + $filter_query = $this->getFilter($filters, true, true); |
|
1250 | 1250 | |
1251 | 1251 | if ($airport != "") |
1252 | 1252 | { |
@@ -1263,8 +1263,8 @@ discard block |
||
1263 | 1263 | { |
1264 | 1264 | $limit_array = explode(",", $limit); |
1265 | 1265 | |
1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1267 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1268 | 1268 | |
1269 | 1269 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1270 | 1270 | { |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $s3 = sin($bank/2); |
44 | 44 | $c1c2 = $c1*$c2; |
45 | 45 | $s1s2 = $s1*$s2; |
46 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
47 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
48 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
46 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
47 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
48 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
51 | 51 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
52 | 52 | |
53 | 53 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $min = false; |
69 | 69 | $allhistory = false; |
70 | 70 | $filter['source'] = array(); |
71 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
72 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
73 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
74 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
75 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
76 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
78 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
79 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
80 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
71 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
73 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
74 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
75 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
77 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
78 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
79 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
80 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
81 | 81 | /* |
82 | 82 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
83 | 83 | $min = true; |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | $from_archive = true; |
125 | 125 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
126 | 126 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
128 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
131 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
132 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
127 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
128 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
131 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
132 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
133 | 133 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
134 | 134 | $from_archive = true; |
135 | 135 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $begindate = $_COOKIE['archive_begin']; |
140 | 140 | $enddate = $_COOKIE['archive_end']; |
141 | 141 | |
142 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
143 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
144 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
142 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
143 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
144 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
145 | 145 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
146 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
146 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
147 | 147 | } elseif ($tracker) { |
148 | 148 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter); |
149 | 149 | } elseif ($marine) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | if (!empty($spotter_array)) { |
156 | 156 | if (isset($_GET['archive'])) { |
157 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
157 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
158 | 158 | } elseif ($tracker) { |
159 | 159 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
160 | 160 | } elseif ($marine) { |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | if ($flightcnt == '') $flightcnt = 0; |
166 | 166 | } else $flightcnt = 0; |
167 | 167 | |
168 | -$sqltime = round(microtime(true)-$begintime,2); |
|
168 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
169 | 169 | $minitime = time(); |
170 | 170 | $maxitime = 0; |
171 | 171 | |
172 | 172 | |
173 | 173 | $modelsdb = array(); |
174 | 174 | if (file_exists('models/modelsdb')) { |
175 | - if (($handle = fopen('models/modelsdb','r')) !== FALSE) { |
|
176 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
177 | - if (isset($row[1]) ){ |
|
175 | + if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) { |
|
176 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
177 | + if (isset($row[1])) { |
|
178 | 178 | $model = $row[0]; |
179 | 179 | $modelsdb[$model] = $row[1]; |
180 | 180 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER","interval": "%minitime%/%maxitime%"}'; |
204 | 204 | } else { |
205 | 205 | if (isset($globalArchive) && $globalArchive === TRUE) { |
206 | - $output .= ',"clock": {"currentTime" : "'.date("c",time()-$globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
206 | + $output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
207 | 207 | } else { |
208 | 208 | $output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $output .= '},'; |
214 | 214 | if (!empty($spotter_array) && is_array($spotter_array)) |
215 | 215 | { |
216 | - foreach($spotter_array as $spotter_item) |
|
216 | + foreach ($spotter_array as $spotter_item) |
|
217 | 217 | { |
218 | 218 | $j++; |
219 | 219 | date_default_timezone_set('UTC'); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $output .= '"cartographicDegrees": ['; |
502 | 502 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
503 | 503 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
504 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
504 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
505 | 505 | $output .= $spotter_item['longitude'].', '; |
506 | 506 | $output .= $spotter_item['latitude']; |
507 | 507 | $prevlong = $spotter_item['longitude']; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
516 | 516 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
517 | 517 | } else { |
518 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
518 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
519 | 519 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
520 | 520 | if ($spotter_item['ground_speed'] == 0) { |
521 | 521 | $output .= $prevlong.', '; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $output = substr($output, 0, -1); |
548 | 548 | } |
549 | 549 | $output .= ']'; |
550 | -$output = str_replace('%minitime%',date("c",$minitime),$output); |
|
551 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
550 | +$output = str_replace('%minitime%', date("c", $minitime), $output); |
|
551 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
552 | 552 | print $output; |
553 | 553 | ?> |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
37 | 37 | if ($flt['airlines'][0] != '') { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
46 | 46 | if (isset($flt['source'])) { |
47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | 48 | } else { |
49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
53 | 53 | if (isset($flt['source'])) { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | 55 | } else { |
56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
60 | 60 | if (isset($flt['source'])) { |
61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | 62 | } else { |
63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
67 | 67 | if (isset($flt['source'])) { |
68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
73 | 73 | if ($filter['airlines'][0] != '') { |
74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
82 | 82 | } |
83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
88 | 88 | } |
89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
114 | 114 | } |
115 | 115 | } |
116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
117 | 117 | } |
118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
120 | 120 | } |
121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
123 | 123 | if ($filter_query_where != '') { |
124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
125 | 125 | } |
126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | if ($limit != '') |
145 | 145 | { |
146 | 146 | $limit_array = explode(',', $limit); |
147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
150 | 150 | { |
151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } else { |
169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
170 | 170 | } |
171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
172 | 172 | |
173 | 173 | return $spotter_array; |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
185 | 185 | date_default_timezone_set('UTC'); |
186 | - $filter_query = $this->getFilter($filter,true,true); |
|
186 | + $filter_query = $this->getFilter($filter, true, true); |
|
187 | 187 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
188 | 188 | if ($globalDBdriver == 'mysql') { |
189 | 189 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | try { |
207 | 207 | $sth = $this->db->prepare($query); |
208 | 208 | $sth->execute(); |
209 | - } catch(PDOException $e) { |
|
209 | + } catch (PDOException $e) { |
|
210 | 210 | echo $e->getMessage(); |
211 | 211 | die; |
212 | 212 | } |
@@ -225,26 +225,26 @@ discard block |
||
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
226 | 226 | date_default_timezone_set('UTC'); |
227 | 227 | |
228 | - $filter_query = $this->getFilter($filter,true,true); |
|
228 | + $filter_query = $this->getFilter($filter, true, true); |
|
229 | 229 | |
230 | 230 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
231 | 231 | if ($globalDBdriver == 'mysql') { |
232 | 232 | if (isset($globalArchive) && $globalArchive === TRUE) { |
233 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
233 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
234 | 234 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id AND spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
235 | 235 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
236 | 236 | } else { |
237 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
237 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | 241 | } else { |
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | - $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
243 | + $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
244 | 244 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
245 | 245 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
246 | 246 | } else { |
247 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
247 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
248 | 248 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
249 | 249 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | - } catch(PDOException $e) { |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo $e->getMessage(); |
258 | 258 | die; |
259 | 259 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
273 | - $filter_query = $this->getFilter($filter,true,true); |
|
273 | + $filter_query = $this->getFilter($filter, true, true); |
|
274 | 274 | |
275 | 275 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
276 | 276 | if ($globalDBdriver == 'mysql') { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | echo $e->getMessage(); |
288 | 288 | die; |
289 | 289 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | $filter_query = $this->getFilter($filter); |
307 | 307 | |
308 | 308 | if (is_array($coord)) { |
309 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
310 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
311 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
312 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
309 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
310 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
311 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
312 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
313 | 313 | } else return array(); |
314 | 314 | if ($globalDBdriver == 'mysql') { |
315 | 315 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
335 | - $filter_query = $this->getFilter($filter,true,true); |
|
335 | + $filter_query = $this->getFilter($filter, true, true); |
|
336 | 336 | |
337 | 337 | if (is_array($coord)) { |
338 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
339 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
340 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
341 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
338 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
339 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
340 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
341 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
342 | 342 | } else return array(); |
343 | 343 | if ($globalDBdriver == 'mysql') { |
344 | 344 | if (isset($globalArchive) && $globalArchive === TRUE) { |
345 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
345 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
346 | 346 | FROM spotter_live |
347 | 347 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
348 | 348 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
349 | 349 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
350 | 350 | } else { |
351 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
351 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
352 | 352 | FROM spotter_live |
353 | 353 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
354 | 354 | FROM spotter_live l |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | } |
361 | 361 | } else { |
362 | 362 | if (isset($globalArchive) && $globalArchive === TRUE) { |
363 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
363 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
364 | 364 | FROM spotter_live |
365 | 365 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
366 | 366 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
367 | 367 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
368 | 368 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
369 | 369 | } else { |
370 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
370 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
371 | 371 | FROM spotter_live |
372 | 372 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
373 | 373 | FROM spotter_live l |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | try { |
383 | 383 | $sth = $this->db->prepare($query); |
384 | 384 | $sth->execute(); |
385 | - } catch(PDOException $e) { |
|
385 | + } catch (PDOException $e) { |
|
386 | 386 | echo $e->getMessage(); |
387 | 387 | die; |
388 | 388 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($interval == '1m') |
432 | 432 | { |
433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
434 | - } else if ($interval == '15m'){ |
|
434 | + } else if ($interval == '15m') { |
|
435 | 435 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
436 | 436 | } |
437 | 437 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
440 | 440 | } |
441 | 441 | |
442 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
442 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
467 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
468 | 468 | |
469 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
469 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
480 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
486 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
489 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
488 | + $date = date('c', $date); |
|
489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
506 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
507 | 507 | |
508 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
508 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @return Array the spotter information |
517 | 517 | * |
518 | 518 | */ |
519 | - public function getDateLiveSpotterDataById($id,$date) |
|
519 | + public function getDateLiveSpotterDataById($id, $date) |
|
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | - $date = date('c',$date); |
|
527 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
525 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | + $date = date('c', $date); |
|
527 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | 546 | try { |
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | echo $e->getMessage(); |
552 | 552 | die; |
553 | 553 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return Array the spotter information |
563 | 563 | * |
564 | 564 | */ |
565 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
565 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
568 | 568 | date_default_timezone_set('UTC'); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | try { |
582 | 582 | $sth = $this->db->prepare($query); |
583 | 583 | $sth->execute(array(':id' => $id)); |
584 | - } catch(PDOException $e) { |
|
584 | + } catch (PDOException $e) { |
|
585 | 585 | echo $e->getMessage(); |
586 | 586 | die; |
587 | 587 | } |
@@ -599,12 +599,12 @@ discard block |
||
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
602 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
603 | 603 | try { |
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo $e->getMessage(); |
609 | 609 | die; |
610 | 610 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
637 | - } catch(PDOException $e) { |
|
637 | + } catch (PDOException $e) { |
|
638 | 638 | return "error"; |
639 | 639 | } |
640 | 640 | |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
660 | - } catch(PDOException $e) { |
|
660 | + } catch (PDOException $e) { |
|
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | 664 | $i = 0; |
665 | - $j =0; |
|
665 | + $j = 0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | - foreach($all as $row) |
|
667 | + foreach ($all as $row) |
|
668 | 668 | { |
669 | 669 | $i++; |
670 | 670 | $j++; |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | if ($globalDebug) echo "."; |
673 | 673 | try { |
674 | 674 | |
675 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
675 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
676 | 676 | $sth->execute(); |
677 | - } catch(PDOException $e) { |
|
677 | + } catch (PDOException $e) { |
|
678 | 678 | return "error"; |
679 | 679 | } |
680 | 680 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | if ($i > 0) { |
686 | 686 | try { |
687 | 687 | |
688 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
688 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
689 | 689 | $sth->execute(); |
690 | - } catch(PDOException $e) { |
|
690 | + } catch (PDOException $e) { |
|
691 | 691 | return "error"; |
692 | 692 | } |
693 | 693 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
703 | - } catch(PDOException $e) { |
|
703 | + } catch (PDOException $e) { |
|
704 | 704 | return "error"; |
705 | 705 | } |
706 | 706 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -748,13 +748,13 @@ discard block |
||
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
751 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
752 | 752 | |
753 | 753 | try { |
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error"; |
759 | 759 | } |
760 | 760 | |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
773 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
774 | 774 | |
775 | 775 | try { |
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | return "error"; |
781 | 781 | } |
782 | 782 | |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
796 | 796 | if ($globalDBdriver == 'mysql') { |
797 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
797 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
798 | 798 | WHERE spotter_live.ident = :ident |
799 | 799 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
800 | 800 | AND spotter_live.date < UTC_TIMESTAMP()'; |
801 | 801 | $query_data = array(':ident' => $ident); |
802 | 802 | } else { |
803 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
803 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
804 | 804 | WHERE spotter_live.ident = :ident |
805 | 805 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
806 | 806 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | |
810 | 810 | $sth = $this->db->prepare($query); |
811 | 811 | $sth->execute($query_data); |
812 | - $ident_result=''; |
|
813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
812 | + $ident_result = ''; |
|
813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | 814 | { |
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
@@ -827,13 +827,13 @@ discard block |
||
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
829 | 829 | if ($globalDBdriver == 'mysql') { |
830 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
830 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
831 | 831 | WHERE spotter_live.ident = :ident |
832 | 832 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
833 | 833 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
834 | 834 | $query_data = array(':ident' => $ident); |
835 | 835 | } else { |
836 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
836 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
837 | 837 | WHERE spotter_live.ident = :ident |
838 | 838 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
839 | 839 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute($query_data); |
845 | - $ident_result=''; |
|
846 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
845 | + $ident_result = ''; |
|
846 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
847 | 847 | { |
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
862 | 862 | if ($globalDBdriver == 'mysql') { |
863 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
863 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
864 | 864 | WHERE spotter_live.flightaware_id = :id |
865 | 865 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
866 | 866 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
867 | 867 | $query_data = array(':id' => $id); |
868 | 868 | } else { |
869 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
869 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
870 | 870 | WHERE spotter_live.flightaware_id = :id |
871 | 871 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
872 | 872 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | |
876 | 876 | $sth = $this->db->prepare($query); |
877 | 877 | $sth->execute($query_data); |
878 | - $ident_result=''; |
|
879 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
878 | + $ident_result = ''; |
|
879 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | 880 | { |
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
@@ -893,13 +893,13 @@ discard block |
||
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
895 | 895 | if ($globalDBdriver == 'mysql') { |
896 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
896 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
897 | 897 | WHERE spotter_live.ModeS = :modes |
898 | 898 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
899 | 899 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
900 | 900 | $query_data = array(':modes' => $modes); |
901 | 901 | } else { |
902 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
902 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
903 | 903 | WHERE spotter_live.ModeS = :modes |
904 | 904 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
905 | 905 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | |
909 | 909 | $sth = $this->db->prepare($query); |
910 | 910 | $sth->execute($query_data); |
911 | - $ident_result=''; |
|
912 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
911 | + $ident_result = ''; |
|
912 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | 913 | { |
914 | 914 | //$ident_result = $row['spotter_live_id']; |
915 | 915 | $ident_result = $row['flightaware_id']; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @return String success or false |
929 | 929 | * |
930 | 930 | */ |
931 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
931 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
934 | 934 | $Common = new Common(); |
@@ -1021,26 +1021,26 @@ discard block |
||
1021 | 1021 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1022 | 1022 | |
1023 | 1023 | |
1024 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1025 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1026 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1027 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1028 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1029 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1032 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1034 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1036 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1037 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1038 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1039 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1040 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1041 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1042 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1043 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1024 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1025 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1026 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1027 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1028 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1029 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1032 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1036 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1037 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1038 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1039 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1040 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1041 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1042 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1043 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1044 | 1044 | |
1045 | 1045 | $airline_name = ''; |
1046 | 1046 | $airline_icao = ''; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1076,19 +1076,19 @@ discard block |
||
1076 | 1076 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1077 | 1077 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
1078 | 1078 | |
1079 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1079 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1080 | 1080 | try { |
1081 | 1081 | |
1082 | 1082 | $sth = $this->db->prepare($query); |
1083 | 1083 | $sth->execute($query_values); |
1084 | 1084 | $sth->closeCursor(); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | 1089 | if ($globalDebug) echo '(Add to SBS archive : '; |
1090 | 1090 | $SpotterArchive = new SpotterArchive($this->db); |
1091 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1091 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1092 | 1092 | if ($globalDebug) echo $result.')'; |
1093 | 1093 | } |
1094 | 1094 | return "success"; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | |
1098 | 1098 | public function getOrderBy() |
1099 | 1099 | { |
1100 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1100 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1101 | 1101 | return $orderby; |
1102 | 1102 | } |
1103 | 1103 |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param String $date get data for a date |
30 | 30 | * @return Array Return Accidents data in array |
31 | 31 | */ |
32 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
32 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
33 | 33 | global $globalURL, $globalDBdriver; |
34 | 34 | $Image = new Image($this->db); |
35 | 35 | $Spotter = new Spotter($this->db); |
36 | 36 | $Translation = new Translation($this->db); |
37 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
37 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | $result = array(); |
40 | 40 | $limit_query = ''; |
41 | 41 | if ($limit != "") |
42 | 42 | { |
43 | 43 | $limit_array = explode(",", $limit); |
44 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
45 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
45 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
46 | 46 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
47 | 47 | { |
48 | 48 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($type != '') { |
53 | 53 | if ($date != '') { |
54 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
54 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
55 | 55 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
56 | 56 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
57 | - $query_values = array(':type' => $type,':date' => $date); |
|
58 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
57 | + $query_values = array(':type' => $type, ':date' => $date); |
|
58 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
59 | 59 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
60 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
60 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
62 | 62 | if ($globalDBdriver == 'mysql') { |
63 | 63 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
64 | 64 | } else { |
65 | 65 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
66 | 66 | } |
67 | - $query_values = array(':type' => $type,':date' => $date); |
|
67 | + $query_values = array(':type' => $type, ':date' => $date); |
|
68 | 68 | } else { |
69 | 69 | $date = $date.'%'; |
70 | 70 | if ($globalDBdriver == 'mysql') { |
71 | 71 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
72 | - $query_values = array(':type' => $type,':date' => $date); |
|
72 | + $query_values = array(':type' => $type, ':date' => $date); |
|
73 | 73 | } else { |
74 | 74 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
75 | 75 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
76 | - $query_values = array(':type' => $type,':date' => $date); |
|
76 | + $query_values = array(':type' => $type, ':date' => $date); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } else { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | if ($date != '') { |
86 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
86 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
89 | 89 | } else { |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | echo "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | $i = 0; |
109 | 109 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 110 | //print_r($row); |
111 | 111 | //echo $row['flightaware_id']; |
112 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
112 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
113 | 113 | $data = array(); |
114 | 114 | if ($row['registration'] != '') { |
115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); |
116 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
117 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
116 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
117 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
118 | 118 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
119 | 119 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
120 | 120 | if (!empty($aircraft_info)) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
123 | 123 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
124 | 124 | } else { |
125 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
125 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
126 | 126 | } |
127 | 127 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
128 | 128 | if (!empty($owner_data)) { |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | $data['aircraft_base'] = $owner_data['base']; |
131 | 131 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
132 | 132 | } |
133 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
133 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
134 | 134 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
135 | 135 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
136 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
136 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
137 | 137 | if (isset($identicao[0])) { |
138 | - if (substr($row['ident'],0,2) == 'AF') { |
|
139 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
142 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
138 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
139 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
141 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
142 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
143 | 143 | } else $icao = $row['ident']; |
144 | - $icao = $Translation->checkTranslation($icao,false); |
|
144 | + $icao = $Translation->checkTranslation($icao, false); |
|
145 | 145 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
146 | 146 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
147 | 147 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | if (!empty($airline_info)) { |
151 | 151 | //echo 'data found !'."\n"; |
152 | 152 | //print_r($airline_info); |
153 | - $data = array_merge($data,$airline_info); |
|
153 | + $data = array_merge($data, $airline_info); |
|
154 | 154 | } |
155 | 155 | //else echo 'No data...'."\n"; |
156 | 156 | } |
157 | - $data = array_merge($row,$data); |
|
157 | + $data = array_merge($row, $data); |
|
158 | 158 | if ($data['ident'] == null) $data['ident'] = $icao; |
159 | 159 | if ($data['title'] == null) { |
160 | 160 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | try { |
191 | 191 | $sth = $this->db->prepare($query); |
192 | 192 | $sth->execute(); |
193 | - } catch(PDOException $e) { |
|
193 | + } catch (PDOException $e) { |
|
194 | 194 | echo "Error : ".$e->getMessage(); |
195 | 195 | } |
196 | 196 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | try { |
211 | 211 | $sth = $this->db->prepare($query); |
212 | 212 | $sth->execute(); |
213 | - } catch(PDOException $e) { |
|
213 | + } catch (PDOException $e) { |
|
214 | 214 | echo "Error : ".$e->getMessage(); |
215 | 215 | } |
216 | 216 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | if ($globalDebug) echo 'Import '.$file."\n"; |
226 | 226 | $result = array(); |
227 | 227 | if (file_exists($file)) { |
228 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
229 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
228 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
229 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
230 | 230 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
231 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
231 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | fclose($handle); |
235 | 235 | } |
236 | - if (!empty($result)) $this->add($result,true); |
|
236 | + if (!empty($result)) $this->add($result, true); |
|
237 | 237 | elseif ($globalDebug) echo 'Nothing to import'; |
238 | 238 | } |
239 | 239 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | $all_md5_new = array(); |
250 | 250 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
251 | 251 | if ($this->check_accidents_nb() > 0) { |
252 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
253 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
252 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
253 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
254 | 254 | if (isset($data[1])) { |
255 | 255 | $year = $data[0]; |
256 | 256 | $all_md5[$year] = $data[1]; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
263 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
264 | 264 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
265 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
266 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
265 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
266 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
267 | 267 | if (isset($data[1])) { |
268 | 268 | $year = $data[0]; |
269 | 269 | $all_md5_new[$year] = $data[1]; |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | fclose($handle); |
273 | 273 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
274 | 274 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
275 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
275 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
276 | 276 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
277 | 277 | foreach ($result as $file => $md5) { |
278 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
278 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
279 | 279 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
280 | 280 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Add data to DB |
286 | 286 | * @param Array $crash An array with accidents/incidents data |
287 | 287 | */ |
288 | - public function add($crash,$new = false) { |
|
288 | + public function add($crash, $new = false) { |
|
289 | 289 | global $globalTransaction, $globalDebug; |
290 | 290 | require_once('class.Connection.php'); |
291 | 291 | require_once('class.Image.php'); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $sthd->execute(array(':source' => $crash[0]['source'])); |
302 | 302 | } |
303 | 303 | if ($globalTransaction) $Connection->db->beginTransaction(); |
304 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
304 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
305 | 305 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
306 | 306 | $sth_check = $Connection->db->prepare($query_check); |
307 | 307 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | $cr = array_map(function($value) { |
315 | 315 | return $value === "" ? NULL : $value; |
316 | 316 | }, $cr); |
317 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
317 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
318 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
320 | 320 | $sth_check->execute($query_check_values); |
321 | 321 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
322 | 322 | if ($result_check['nb'] == 0) { |
323 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
323 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
324 | 324 | $sth->execute($query_values); |
325 | - if ($cr['date'] > time()-(30*86400)) { |
|
325 | + if ($cr['date'] > time() - (30*86400)) { |
|
326 | 326 | if (empty($Image->getSpotterImage($cr['registration']))) { |
327 | 327 | //if ($globalDebug) echo 'Get image...'."\n"; |
328 | 328 | $Image->addSpotterImage($cr['registration']); |
329 | 329 | } |
330 | 330 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
331 | 331 | } |
332 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
332 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
333 | 333 | } |
334 | 334 | } |
335 | - if ($globalTransaction && $j % 1000 == 0) { |
|
335 | + if ($globalTransaction && $j%1000 == 0) { |
|
336 | 336 | $Connection->db->commit(); |
337 | 337 | $Connection->db->beginTransaction(); |
338 | 338 | } |
339 | 339 | } |
340 | 340 | if ($globalTransaction) $Connection->db->commit(); |
341 | - } catch(PDOException $e) { |
|
341 | + } catch (PDOException $e) { |
|
342 | 342 | if ($globalTransaction) $Connection->db->rollBack(); |
343 | 343 | echo $e->getMessage(); |
344 | 344 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $Connection = new Connection(); |
357 | 357 | $sth = $Connection->db->prepare($query); |
358 | 358 | $sth->execute(); |
359 | - } catch(PDOException $e) { |
|
359 | + } catch (PDOException $e) { |
|
360 | 360 | return "error : ".$e->getMessage(); |
361 | 361 | } |
362 | 362 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $Connection = new Connection(); |
375 | 375 | $sth = $Connection->db->prepare($query); |
376 | 376 | $sth->execute(); |
377 | - } catch(PDOException $e) { |
|
377 | + } catch (PDOException $e) { |
|
378 | 378 | return "error : ".$e->getMessage(); |
379 | 379 | } |
380 | 380 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | 391 | $sth->execute(); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | return "error : ".$e->getMessage(); |
394 | 394 | } |
395 | 395 | } |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime); |
|
17 | 17 | if (empty($spotter_array)) { |
18 | 18 | $from_archive = true; |
19 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime); |
|
19 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($_GET['flightaware_id'])) { |
30 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
30 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
31 | 31 | if (isset($_GET['currenttime'])) { |
32 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
32 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
33 | 33 | $currenttime = round($currenttime/1000); |
34 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime); |
|
34 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime); |
|
35 | 35 | if (empty($spotter_array)) { |
36 | 36 | $from_archive = true; |
37 | 37 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
38 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime); |
|
38 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime); |
|
39 | 39 | } |
40 | 40 | } else { |
41 | 41 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
55 | 55 | { |
56 | 56 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
57 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
57 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
58 | 58 | } else $image = $spotter_item['image_thumbnail']; |
59 | 59 | |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
73 | 73 | if (isset($spotter_item['departure_airport_time'])) { |
74 | 74 | if ($spotter_item['departure_airport_time'] > 2460) { |
75 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
75 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
76 | 76 | } else { |
77 | 77 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
82 | 82 | if (isset($spotter_item['arrival_airport_time'])) { |
83 | 83 | if ($spotter_item['arrival_airport_time'] > 2460) { |
84 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
84 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
85 | 85 | } else { |
86 | 86 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
87 | 87 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
153 | 153 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
154 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
154 | +if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>'; |
|
155 | 155 | if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
156 | 156 | print '</div>'; |
157 | 157 | ?> |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
119 | 119 | } |
120 | 120 | } |
121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
121 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
122 | 122 | |
123 | 123 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
124 | 124 | if ($globalDBdriver == 'mysql') { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } else { |
128 | 128 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
129 | 129 | } |
130 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
130 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
131 | 131 | |
132 | 132 | return $spotter_array; |
133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
144 | 144 | date_default_timezone_set('UTC'); |
145 | 145 | |
146 | - $filter_query = $this->getFilter($filter,true,true); |
|
146 | + $filter_query = $this->getFilter($filter, true, true); |
|
147 | 147 | |
148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | try { |
158 | 158 | $sth = $this->db->prepare($query); |
159 | 159 | $sth->execute(); |
160 | - } catch(PDOException $e) { |
|
160 | + } catch (PDOException $e) { |
|
161 | 161 | echo $e->getMessage(); |
162 | 162 | die; |
163 | 163 | } |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | global $globalDBdriver, $globalLiveInterval; |
178 | 178 | date_default_timezone_set('UTC'); |
179 | 179 | |
180 | - $filter_query = $this->getFilter($filter,true,true); |
|
180 | + $filter_query = $this->getFilter($filter, true, true); |
|
181 | 181 | |
182 | 182 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
183 | 183 | if ($globalDBdriver == 'mysql') { |
184 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
184 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
185 | 185 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
186 | 186 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
187 | 187 | } else { |
188 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
188 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
189 | 189 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
190 | 190 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | try { |
194 | 194 | $sth = $this->db->prepare($query); |
195 | 195 | $sth->execute(); |
196 | - } catch(PDOException $e) { |
|
196 | + } catch (PDOException $e) { |
|
197 | 197 | echo $e->getMessage(); |
198 | 198 | die; |
199 | 199 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | public function getLiveMarineCount($filter = array()) |
211 | 211 | { |
212 | 212 | global $globalDBdriver, $globalLiveInterval; |
213 | - $filter_query = $this->getFilter($filter,true,true); |
|
213 | + $filter_query = $this->getFilter($filter, true, true); |
|
214 | 214 | |
215 | 215 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
216 | 216 | if ($globalDBdriver == 'mysql') { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | 223 | $sth->execute(); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo $e->getMessage(); |
226 | 226 | die; |
227 | 227 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | $filter_query = $this->getFilter($filter); |
245 | 245 | |
246 | 246 | if (is_array($coord)) { |
247 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
248 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
249 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
247 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
248 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
249 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | 251 | } else return array(); |
252 | 252 | if ($globalDBdriver == 'mysql') { |
253 | 253 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | $filter_query = $this->getFilter($filter); |
273 | 273 | |
274 | 274 | if (is_array($coord)) { |
275 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
276 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
277 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
275 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
276 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
277 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | 279 | } else return array(); |
280 | 280 | if ($globalDBdriver == 'mysql') { |
281 | 281 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
282 | 282 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
283 | 283 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
284 | 284 | } else { |
285 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
285 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
286 | 286 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
287 | 287 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
288 | 288 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($interval == '1m') |
332 | 332 | { |
333 | 333 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
334 | - } else if ($interval == '15m'){ |
|
334 | + } else if ($interval == '15m') { |
|
335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
336 | 336 | } |
337 | 337 | } |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
340 | 340 | } |
341 | 341 | |
342 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
342 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
343 | 343 | WHERE marine_live.latitude <> '' |
344 | 344 | AND marine_live.longitude <> '' |
345 | 345 | ".$additional_query." |
346 | 346 | HAVING distance < :radius |
347 | 347 | ORDER BY distance"; |
348 | 348 | |
349 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
349 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
350 | 350 | |
351 | 351 | return $spotter_array; |
352 | 352 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | date_default_timezone_set('UTC'); |
365 | 365 | |
366 | 366 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
367 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
367 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
368 | 368 | |
369 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
369 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
370 | 370 | |
371 | 371 | return $spotter_array; |
372 | 372 | } |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | * @return Array the spotter information |
378 | 378 | * |
379 | 379 | */ |
380 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
380 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
381 | 381 | { |
382 | 382 | $Marine = new Marine($this->db); |
383 | 383 | date_default_timezone_set('UTC'); |
384 | 384 | |
385 | 385 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
386 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
386 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
387 | 387 | |
388 | - $date = date('c',$date); |
|
389 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
388 | + $date = date('c', $date); |
|
389 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
390 | 390 | |
391 | 391 | return $spotter_array; |
392 | 392 | } |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | date_default_timezone_set('UTC'); |
404 | 404 | |
405 | 405 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
407 | 407 | |
408 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
408 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
409 | 409 | |
410 | 410 | return $spotter_array; |
411 | 411 | } |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @return Array the spotter information |
417 | 417 | * |
418 | 418 | */ |
419 | - public function getDateLiveMarineDataById($id,$date) |
|
419 | + public function getDateLiveMarineDataById($id, $date) |
|
420 | 420 | { |
421 | 421 | $Marine = new Marine($this->db); |
422 | 422 | date_default_timezone_set('UTC'); |
423 | 423 | |
424 | 424 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
426 | - $date = date('c',$date); |
|
427 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
426 | + $date = date('c', $date); |
|
427 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
428 | 428 | |
429 | 429 | return $spotter_array; |
430 | 430 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * @return Array the spotter information |
437 | 437 | * |
438 | 438 | */ |
439 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
439 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
440 | 440 | { |
441 | 441 | global $globalDBdriver, $globalLiveInterval; |
442 | 442 | date_default_timezone_set('UTC'); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | try { |
456 | 456 | $sth = $this->db->prepare($query); |
457 | 457 | $sth->execute(array(':id' => $id)); |
458 | - } catch(PDOException $e) { |
|
458 | + } catch (PDOException $e) { |
|
459 | 459 | echo $e->getMessage(); |
460 | 460 | die; |
461 | 461 | } |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | { |
474 | 474 | date_default_timezone_set('UTC'); |
475 | 475 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
476 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
476 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
477 | 477 | try { |
478 | 478 | |
479 | 479 | $sth = $this->db->prepare($query); |
480 | 480 | $sth->execute(array(':ident' => $ident)); |
481 | - } catch(PDOException $e) { |
|
481 | + } catch (PDOException $e) { |
|
482 | 482 | echo $e->getMessage(); |
483 | 483 | die; |
484 | 484 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $sth = $this->db->prepare($query); |
510 | 510 | $sth->execute(); |
511 | - } catch(PDOException $e) { |
|
511 | + } catch (PDOException $e) { |
|
512 | 512 | return "error"; |
513 | 513 | } |
514 | 514 | |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(); |
534 | - } catch(PDOException $e) { |
|
534 | + } catch (PDOException $e) { |
|
535 | 535 | return "error"; |
536 | 536 | } |
537 | 537 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
538 | 538 | $i = 0; |
539 | - $j =0; |
|
539 | + $j = 0; |
|
540 | 540 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
541 | - foreach($all as $row) |
|
541 | + foreach ($all as $row) |
|
542 | 542 | { |
543 | 543 | $i++; |
544 | 544 | $j++; |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | if ($globalDebug) echo "."; |
547 | 547 | try { |
548 | 548 | |
549 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
549 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
550 | 550 | $sth->execute(); |
551 | - } catch(PDOException $e) { |
|
551 | + } catch (PDOException $e) { |
|
552 | 552 | return "error"; |
553 | 553 | } |
554 | 554 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | if ($i > 0) { |
560 | 560 | try { |
561 | 561 | |
562 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
562 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
563 | 563 | $sth->execute(); |
564 | - } catch(PDOException $e) { |
|
564 | + } catch (PDOException $e) { |
|
565 | 565 | return "error"; |
566 | 566 | } |
567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | $sth = $this->db->prepare($query); |
576 | 576 | $sth->execute(); |
577 | - } catch(PDOException $e) { |
|
577 | + } catch (PDOException $e) { |
|
578 | 578 | return "error"; |
579 | 579 | } |
580 | 580 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | public function deleteLiveMarineDataByIdent($ident) |
623 | 623 | { |
624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
625 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
625 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
626 | 626 | |
627 | 627 | try { |
628 | 628 | |
629 | 629 | $sth = $this->db->prepare($query); |
630 | 630 | $sth->execute(array(':ident' => $ident)); |
631 | - } catch(PDOException $e) { |
|
631 | + } catch (PDOException $e) { |
|
632 | 632 | return "error"; |
633 | 633 | } |
634 | 634 | |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | public function deleteLiveMarineDataById($id) |
645 | 645 | { |
646 | 646 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
647 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
647 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
648 | 648 | |
649 | 649 | try { |
650 | 650 | |
651 | 651 | $sth = $this->db->prepare($query); |
652 | 652 | $sth->execute(array(':id' => $id)); |
653 | - } catch(PDOException $e) { |
|
653 | + } catch (PDOException $e) { |
|
654 | 654 | return "error"; |
655 | 655 | } |
656 | 656 | |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | { |
669 | 669 | global $globalDBdriver, $globalTimezone; |
670 | 670 | if ($globalDBdriver == 'mysql') { |
671 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
671 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
672 | 672 | WHERE marine_live.ident = :ident |
673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
674 | 674 | AND marine_live.date < UTC_TIMESTAMP()'; |
675 | 675 | $query_data = array(':ident' => $ident); |
676 | 676 | } else { |
677 | - $query = "SELECT marine_live.ident FROM marine_live |
|
677 | + $query = "SELECT marine_live.ident FROM marine_live |
|
678 | 678 | WHERE marine_live.ident = :ident |
679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
680 | 680 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | |
684 | 684 | $sth = $this->db->prepare($query); |
685 | 685 | $sth->execute($query_data); |
686 | - $ident_result=''; |
|
687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
686 | + $ident_result = ''; |
|
687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
688 | 688 | { |
689 | 689 | $ident_result = $row['ident']; |
690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
701 | 701 | { |
702 | 702 | global $globalDBdriver, $globalTimezone; |
703 | 703 | if ($globalDBdriver == 'mysql') { |
704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
705 | 705 | WHERE marine_live.ident = :ident |
706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
708 | 708 | $query_data = array(':ident' => $ident); |
709 | 709 | } else { |
710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
711 | 711 | WHERE marine_live.ident = :ident |
712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | |
717 | 717 | $sth = $this->db->prepare($query); |
718 | 718 | $sth->execute($query_data); |
719 | - $ident_result=''; |
|
720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
719 | + $ident_result = ''; |
|
720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
721 | 721 | { |
722 | 722 | $ident_result = $row['fammarine_id']; |
723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
737 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
738 | 738 | WHERE marine_live.fammarine_id = :id |
739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
741 | 741 | $query_data = array(':id' => $id); |
742 | 742 | } else { |
743 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
743 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
744 | 744 | WHERE marine_live.fammarine_id = :id |
745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
752 | + $ident_result = ''; |
|
753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
754 | 754 | { |
755 | 755 | $ident_result = $row['fammarine_id']; |
756 | 756 | } |
@@ -767,13 +767,13 @@ discard block |
||
767 | 767 | { |
768 | 768 | global $globalDBdriver, $globalTimezone; |
769 | 769 | if ($globalDBdriver == 'mysql') { |
770 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
770 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
771 | 771 | WHERE marine_live.mmsi = :mmsi |
772 | 772 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
773 | 773 | // AND marine_live.date < UTC_TIMESTAMP()"; |
774 | 774 | $query_data = array(':mmsi' => $mmsi); |
775 | 775 | } else { |
776 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
776 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
777 | 777 | WHERE marine_live.mmsi = :mmsi |
778 | 778 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
779 | 779 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | |
783 | 783 | $sth = $this->db->prepare($query); |
784 | 784 | $sth->execute($query_data); |
785 | - $ident_result=''; |
|
786 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
785 | + $ident_result = ''; |
|
786 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
787 | 787 | { |
788 | 788 | $ident_result = $row['fammarine_id']; |
789 | 789 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @return String success or false |
802 | 802 | * |
803 | 803 | */ |
804 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
804 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
805 | 805 | { |
806 | 806 | global $globalURL, $globalArchive, $globalDebug; |
807 | 807 | $Common = new Common(); |
@@ -853,26 +853,26 @@ discard block |
||
853 | 853 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
854 | 854 | |
855 | 855 | |
856 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
857 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
858 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
859 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
860 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
861 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
862 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
863 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
864 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
865 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
866 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
867 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
868 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
869 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
870 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
871 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
856 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
857 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
858 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
859 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
860 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
861 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
862 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
863 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
864 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
865 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
866 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
867 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
868 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
869 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
870 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
871 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
872 | 872 | |
873 | 873 | |
874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
874 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
875 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
876 | 876 | if ($arrival_date == '') $arrival_date = NULL; |
877 | 877 | $query = ''; |
878 | 878 | if ($globalArchive) { |
@@ -882,18 +882,18 @@ discard block |
||
882 | 882 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
883 | 883 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
884 | 884 | |
885 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
885 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
886 | 886 | try { |
887 | 887 | $sth = $this->db->prepare($query); |
888 | 888 | $sth->execute($query_values); |
889 | - } catch(PDOException $e) { |
|
889 | + } catch (PDOException $e) { |
|
890 | 890 | return "error : ".$e->getMessage(); |
891 | 891 | } |
892 | 892 | |
893 | 893 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
894 | 894 | if ($globalDebug) echo '(Add to Marine archive : '; |
895 | 895 | $MarineArchive = new MarineArchive($this->db); |
896 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
896 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
897 | 897 | if ($globalDebug) echo $result.')'; |
898 | 898 | } |
899 | 899 | return "success"; |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | |
902 | 902 | public function getOrderBy() |
903 | 903 | { |
904 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
904 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
905 | 905 | return $orderby; |
906 | 906 | } |
907 | 907 |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | * @return Array the images list |
18 | 18 | * |
19 | 19 | */ |
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
21 | 21 | { |
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
25 | 25 | $reg = $registration; |
26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
27 | 27 | $reg = trim($reg); |
28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | 29 | FROM spotter_image |
30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
31 | 31 | $sth = $this->db->prepare($query); |
32 | 32 | $sth->execute(array(':registration' => $reg)); |
33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
34 | 34 | if (!empty($result)) return $result; |
35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
36 | 36 | else return array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * @return Array the images list |
43 | 43 | * |
44 | 44 | */ |
45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
46 | 46 | { |
47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
50 | 50 | $name = trim($name); |
51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | 52 | FROM marine_image |
53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
54 | 54 | $query_data = array(':mmsi' => $mmsi); |
55 | 55 | if ($imo != '') { |
56 | 56 | $query .= " AND marine_image.imo = :imo"; |
57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
58 | 58 | } |
59 | 59 | if ($name != '') { |
60 | 60 | $query .= " AND marine_image.name = :name"; |
61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
62 | 62 | } |
63 | 63 | $query .= " LIMIT 1"; |
64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
81 | 81 | if ($copyright != '') { |
82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
83 | - $copyright = str_replace('© ','',$copyright); |
|
84 | - $copyright = str_replace('(c) ','',$copyright); |
|
82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
83 | + $copyright = str_replace('© ', '', $copyright); |
|
84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
85 | 85 | } |
86 | 86 | return $copyright; |
87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * @return String either success or error |
93 | 93 | * |
94 | 94 | */ |
95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
96 | 96 | { |
97 | - global $globalDebug,$globalAircraftImageFetch; |
|
97 | + global $globalDebug, $globalAircraftImageFetch; |
|
98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
100 | 100 | $registration = trim($registration); |
101 | 101 | //getting the aircraft image |
102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
107 | 107 | if ($image_url['original'] != '') { |
108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | 110 | try { |
111 | 111 | $sth = $this->db->prepare($query); |
112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
113 | - } catch(PDOException $e) { |
|
112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | echo $e->getMessage()."\n"; |
115 | 115 | return "error"; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @return String either success or error |
125 | 125 | * |
126 | 126 | */ |
127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
128 | 128 | { |
129 | - global $globalDebug,$globalMarineImageFetch; |
|
129 | + global $globalDebug, $globalMarineImageFetch; |
|
130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
134 | 134 | $name = trim($name); |
135 | 135 | $Marine = new Marine($this->db); |
136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | |
145 | 145 | //getting the aircraft image |
146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
148 | 148 | if ($image_url['original'] != '') { |
149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | 151 | try { |
152 | 152 | $sth = $this->db->prepare($query); |
153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
154 | - } catch(PDOException $e) { |
|
153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
154 | + } catch (PDOException $e) { |
|
155 | 155 | echo $e->getMessage()."\n"; |
156 | 156 | return "error"; |
157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
172 | 172 | $Spotter = new Spotter($this->db); |
173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
175 | 175 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
188 | 188 | else $aircraft_name = ''; |
189 | 189 | $aircraft_registration = $aircraft_icao; |
190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
191 | 191 | unset($Spotter); |
192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
193 | 193 | foreach ($globalAircraftImageSources as $source) { |
194 | 194 | $source = strtolower($source); |
195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
206 | 206 | } |
207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
218 | 218 | * |
219 | 219 | */ |
220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
221 | 221 | { |
222 | 222 | global $globalMarineImageSources; |
223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
224 | 224 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
226 | 226 | $name = trim($name); |
227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
228 | 228 | /* |
229 | 229 | $Marine = new Marine($this->db); |
230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | unset($Marine); |
238 | 238 | */ |
239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
240 | 240 | foreach ($globalMarineImageSources as $source) { |
241 | 241 | $source = strtolower($source); |
242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
248 | 248 | } |
249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
258 | 258 | * |
259 | 259 | */ |
260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
261 | 261 | $Common = new Common(); |
262 | 262 | // If aircraft registration is only number, also check with aircraft model |
263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
265 | 265 | } else { |
266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | 268 | } |
269 | 269 | $data = $Common->getData($url); |
270 | 270 | if ($xml = simplexml_load_string($data)) { |
271 | 271 | if (isset($xml->channel->item)) { |
272 | 272 | $image_url = array(); |
273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
278 | 278 | $image_url['source'] = 'planespotters'; |
279 | 279 | return $image_url; |
280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
291 | 291 | * |
292 | 292 | */ |
293 | - public function fromDeviantart($type,$registration, $name='') { |
|
293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
294 | 294 | $Common = new Common(); |
295 | 295 | if ($type == 'aircraft') { |
296 | 296 | // If aircraft registration is only number, also check with aircraft model |
297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | 299 | } else { |
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
301 | 301 | } |
302 | 302 | } elseif ($type == 'marine') { |
303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $data = $Common->getData($url); |
307 | 307 | if ($xml = simplexml_load_string($data)) { |
308 | 308 | if (isset($xml->channel->item->link)) { |
309 | 309 | $image_url = array(); |
310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
313 | 313 | $image_url['original'] = $original_url; |
314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
316 | 316 | $image_url['source'] = 'deviantart'; |
317 | 317 | return $image_url; |
318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
329 | 329 | * |
330 | 330 | */ |
331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
332 | 332 | $Common = new Common(); |
333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
334 | 334 | $data = $Common->getData($url); |
335 | 335 | $dom = new DOMDocument(); |
336 | 336 | @$dom->loadHTML($data); |
337 | 337 | $all_pics = array(); |
338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
340 | 340 | $all_pics[] = $image->getAttribute('src'); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | $all_authors = array(); |
344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
346 | 346 | $all_authors[] = $author->getAttribute('content'); |
347 | 347 | } |
348 | 348 | } |
349 | 349 | $all_ref = array(); |
350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
351 | 351 | $all_ref[] = $link->getAttribute('href'); |
352 | 352 | } |
353 | 353 | if (isset($all_pics[0])) { |
354 | 354 | $image_url = array(); |
355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
357 | 357 | $image_url['copyright'] = $all_authors[0]; |
358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
371 | 371 | * |
372 | 372 | */ |
373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
374 | 374 | $Common = new Common(); |
375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
376 | 376 | $data = $Common->getData($url); |
377 | 377 | $dom = new DOMDocument(); |
378 | 378 | @$dom->loadHTML($data); |
379 | 379 | $all_pics = array(); |
380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
381 | 381 | $all_pics[] = $image->getAttribute('src'); |
382 | 382 | } |
383 | 383 | $all_links = array(); |
384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
386 | 386 | } |
387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
388 | 388 | $image_url = array(); |
389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
405 | 405 | * |
406 | 406 | */ |
407 | - public function fromFlickr($type,$registration,$name='') { |
|
407 | + public function fromFlickr($type, $registration, $name = '') { |
|
408 | 408 | $Common = new Common(); |
409 | 409 | if ($type == 'aircraft') { |
410 | 410 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $data = $Common->getData($url); |
417 | 417 | if ($xml = simplexml_load_string($data)) { |
418 | 418 | if (isset($xml->channel->item)) { |
419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
420 | 420 | $image_url = array(); |
421 | 421 | $image_url['thumbnail'] = $original_url; |
422 | 422 | $image_url['original'] = $original_url; |
423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
425 | 425 | $image_url['source'] = 'flickr'; |
426 | 426 | return $image_url; |
427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
433 | 433 | $Common = new Common(); |
434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
454 | 454 | * |
455 | 455 | */ |
456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
457 | 457 | global $globalImageBingKey; |
458 | 458 | $Common = new Common(); |
459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
465 | 465 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
466 | 466 | } |
467 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
468 | - $data = $Common->getData($url,'get','',$headers); |
|
467 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
468 | + $data = $Common->getData($url, 'get', '', $headers); |
|
469 | 469 | $result = json_decode($data); |
470 | 470 | if (isset($result->d->results[0]->MediaUrl)) { |
471 | 471 | $image_url = array(); |
@@ -490,14 +490,14 @@ discard block |
||
490 | 490 | * @return Array the aircraft thumbnail, orignal url and copyright |
491 | 491 | * |
492 | 492 | */ |
493 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
493 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
494 | 494 | $Common = new Common(); |
495 | 495 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
496 | 496 | $data = $Common->getData($url); |
497 | 497 | $result = json_decode($data); |
498 | 498 | if (isset($result->count) && $result->count > 0) { |
499 | 499 | $image_url = array(); |
500 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
500 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
501 | 501 | $image_url['source_website'] = $result->data[0]->link; |
502 | 502 | $image_url['thumbnail'] = $result->data[0]->image; |
503 | 503 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return Array the aircraft thumbnail, orignal url and copyright |
516 | 516 | * |
517 | 517 | */ |
518 | - public function fromWikimedia($type,$registration,$name='') { |
|
518 | + public function fromWikimedia($type, $registration, $name = '') { |
|
519 | 519 | $Common = new Common(); |
520 | 520 | if ($type == 'aircraft') { |
521 | 521 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | $result = json_decode($data); |
529 | 529 | if (isset($result->query->search[0]->title)) { |
530 | 530 | $fileo = $result->query->search[0]->title; |
531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
531 | + if (substr($fileo, -3) == 'pdf') return false; |
|
532 | 532 | $file = urlencode($fileo); |
533 | 533 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
534 | 534 | $data2 = $Common->getData($url2); |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | if (isset($result2->query->pages)) { |
554 | 554 | foreach ($result2->query->pages as $page) { |
555 | 555 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
556 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
556 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
557 | 557 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
558 | 558 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
559 | 559 | } |
560 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
560 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
561 | 561 | return $image_url; |
562 | 562 | } |
563 | 563 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return Array the aircraft thumbnail, orignal url and copyright |
577 | 577 | * |
578 | 578 | */ |
579 | - public function fromCustomSource($type,$registration,$name='') { |
|
579 | + public function fromCustomSource($type, $registration, $name = '') { |
|
580 | 580 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
581 | 581 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
582 | 582 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | print_r($source); |
594 | 594 | print_r($customsources); |
595 | 595 | } |
596 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
597 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
596 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
597 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
598 | 598 | if ($Common->urlexist($url)) { |
599 | 599 | $image_url = array(); |
600 | 600 | $image_url['thumbnail'] = $url_thumbnail; |
601 | 601 | $image_url['original'] = $url; |
602 | 602 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
603 | 603 | else $exifCopyright = ''; |
604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
604 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
605 | 605 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
606 | 606 | else $image_url['copyright'] = $source['source_website']; |
607 | 607 | $image_url['source_website'] = $source['source_website']; |
@@ -625,19 +625,19 @@ discard block |
||
625 | 625 | print_r($source); |
626 | 626 | print_r($customsources); |
627 | 627 | } |
628 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
629 | - $url = str_replace('{mmsi}',$registration,$url); |
|
630 | - $url = str_replace('{name}',$name,$url); |
|
631 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
632 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
633 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
628 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
629 | + $url = str_replace('{mmsi}', $registration, $url); |
|
630 | + $url = str_replace('{name}', $name, $url); |
|
631 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
632 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
633 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
634 | 634 | if ($Common->urlexist($url)) { |
635 | 635 | $image_url = array(); |
636 | 636 | $image_url['thumbnail'] = $url_thumbnail; |
637 | 637 | $image_url['original'] = $url; |
638 | 638 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
639 | 639 | else $exifCopyright = ''; |
640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
640 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
641 | 641 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
642 | 642 | else $image_url['copyright'] = $source['source_website']; |
643 | 643 | $image_url['source_website'] = $source['source_website']; |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,20 +385,20 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
398 | - $seq = (int)$pcs[2]; // get sequence |
|
397 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
398 | + $seq = (int) $pcs[2]; // get sequence |
|
399 | 399 | // get msg sequence id |
400 | 400 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
401 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
402 | 402 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 403 | // message sequence checking |
404 | 404 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | - $filler += (int)$pcs[6][0]; // get filler |
|
434 | + $filler += (int) $pcs[6][0]; // get filler |
|
435 | 435 | if ($num_seq == 1 // valid single message |
436 | 436 | || $num_seq == $pseq // valid multi-part message |
437 | 437 | ) { |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | $cbuf = $cbuf.$ibuf; |
452 | 452 | $last_pos = 0; |
453 | 453 | $result = new stdClass(); |
454 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
454 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
455 | 455 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
456 | 456 | //DEBUG echo $cbuf; |
457 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
457 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
458 | 458 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
459 | 459 | //DEBUG echo "[$start $end $tst]\n"; |
460 | - $result = $this->process_ais_raw( $tst, "" ); |
|
460 | + $result = $this->process_ais_raw($tst, ""); |
|
461 | 461 | $last_pos = $end + 1; |
462 | 462 | } else break; |
463 | 463 | } |
@@ -469,41 +469,41 @@ discard block |
||
469 | 469 | // incoming data from serial or IP comms |
470 | 470 | public function process_ais_line($cbuf) { |
471 | 471 | $result = new stdClass(); |
472 | - $start = strpos($cbuf,"VDM"); |
|
472 | + $start = strpos($cbuf, "VDM"); |
|
473 | 473 | $tst = substr($cbuf, $start - 3); |
474 | - $result = $this->process_ais_raw( $tst, "" ); |
|
474 | + $result = $this->process_ais_raw($tst, ""); |
|
475 | 475 | return $result; |
476 | 476 | } |
477 | 477 | |
478 | 478 | /* AIS Encoding |
479 | 479 | */ |
480 | - private function mk_ais_lat( $lat ) { |
|
480 | + private function mk_ais_lat($lat) { |
|
481 | 481 | //$lat = 1.2569; |
482 | - if ($lat<0.0) { |
|
482 | + if ($lat < 0.0) { |
|
483 | 483 | $lat = -$lat; |
484 | - $neg=true; |
|
485 | - } else $neg=false; |
|
484 | + $neg = true; |
|
485 | + } else $neg = false; |
|
486 | 486 | $latd = 0x00000000; |
487 | - $latd = intval ($lat * 600000.0); |
|
488 | - if ($neg==true) { |
|
487 | + $latd = intval($lat*600000.0); |
|
488 | + if ($neg == true) { |
|
489 | 489 | $latd = ~$latd; |
490 | - $latd+=1; |
|
490 | + $latd += 1; |
|
491 | 491 | $latd &= 0x07FFFFFF; |
492 | 492 | } |
493 | 493 | return $latd; |
494 | 494 | } |
495 | 495 | |
496 | - private function mk_ais_lon( $lon ) { |
|
496 | + private function mk_ais_lon($lon) { |
|
497 | 497 | //$lon = 103.851; |
498 | - if ($lon<0.0) { |
|
498 | + if ($lon < 0.0) { |
|
499 | 499 | $lon = -$lon; |
500 | - $neg=true; |
|
501 | - } else $neg=false; |
|
500 | + $neg = true; |
|
501 | + } else $neg = false; |
|
502 | 502 | $lond = 0x00000000; |
503 | - $lond = intval ($lon * 600000.0); |
|
504 | - if ($neg==true) { |
|
503 | + $lond = intval($lon*600000.0); |
|
504 | + if ($neg == true) { |
|
505 | 505 | $lond = ~$lond; |
506 | - $lond+=1; |
|
506 | + $lond += 1; |
|
507 | 507 | $lond &= 0x0FFFFFFF; |
508 | 508 | } |
509 | 509 | return $lond; |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | |
512 | 512 | private function char2bin($name, $max_len) { |
513 | 513 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
514 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
515 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
@@ -529,26 +529,26 @@ discard block |
||
529 | 529 | if ($_a) foreach ($_a as $_1) { |
530 | 530 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | 531 | else $dec = 0; |
532 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
532 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
533 | 533 | $rv .= $bin; |
534 | 534 | //echo "$_1 $dec ($bin)<br/>"; |
535 | 535 | } |
536 | 536 | return $rv.$pad; |
537 | 537 | } |
538 | 538 | |
539 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
539 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
540 | 540 | $len_bit = strlen($_enc); |
541 | - $rem6 = $len_bit % 6; |
|
541 | + $rem6 = $len_bit%6; |
|
542 | 542 | $pad6_len = 0; |
543 | 543 | if ($rem6) $pad6_len = 6 - $rem6; |
544 | 544 | //echo $pad6_len.'<br>'; |
545 | 545 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | - $len_enc = strlen($_enc) / 6; |
|
546 | + $len_enc = strlen($_enc)/6; |
|
547 | 547 | //echo $_enc.' '.$len_enc.'<br/>'; |
548 | 548 | $itu = ''; |
549 | - for ($i=0; $i<$len_enc; $i++) { |
|
550 | - $offset = $i * 6; |
|
551 | - $dec = bindec(substr($_enc,$offset,6)); |
|
549 | + for ($i = 0; $i < $len_enc; $i++) { |
|
550 | + $offset = $i*6; |
|
551 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
552 | 552 | if ($dec < 40) $dec += 48; |
553 | 553 | else $dec += 56; |
554 | 554 | //echo chr($dec)." $dec<br/>"; |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | $chksum = 0; |
559 | 559 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
560 | 560 | $len_itu = strlen($itu); |
561 | - for ($i=0; $i<$len_itu; $i++) { |
|
562 | - $chksum ^= ord( $itu[$i] ); |
|
561 | + for ($i = 0; $i < $len_itu; $i++) { |
|
562 | + $chksum ^= ord($itu[$i]); |
|
563 | 563 | } |
564 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
565 | - $lsb = $chksum & 0x0F; |
|
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
564 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
565 | + $lsb = $chksum&0x0F; |
|
566 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
567 | 567 | else $lsbc = '0'; |
568 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
568 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
569 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
570 | 570 | else $msbc = '0'; |
571 | 571 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 572 | return $itu; |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | |
592 | 592 | public function mmsitype($mmsi) { |
593 | 593 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
594 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
600 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
601 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
602 | 602 | else return 'Ship'; |
603 | 603 | } |
604 | 604 | |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | global $globalDebug; |
610 | 610 | $result = array(); |
611 | 611 | $data = new stdClass(); |
612 | - $start = strpos($buffer,"VDM"); |
|
612 | + $start = strpos($buffer, "VDM"); |
|
613 | 613 | $tst = substr($buffer, $start - 3); |
614 | - $data = $this->process_ais_raw( $tst, "" ); |
|
614 | + $data = $this->process_ais_raw($tst, ""); |
|
615 | 615 | if (!is_object($data)) { |
616 | 616 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 617 | return array(); |
618 | 618 | } |
619 | 619 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
620 | 620 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
621 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
621 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
622 | 622 | $result['timestamp'] = $data->ts; |
623 | 623 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
624 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
625 | 625 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | 626 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
627 | 627 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | if ($data->type !== '') $result['type'] = $data->type; |
632 | 632 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
633 | 633 | if ($data->imo !== '') $result['imo'] = $data->imo; |
634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
634 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
635 | 635 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
636 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
636 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
637 | 637 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
638 | 638 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
639 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
639 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
640 | 640 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
641 | 641 | } |
642 | 642 | if ($data->destination != '') { |
643 | - $dest = trim(str_replace('@','',$data->destination)); |
|
643 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
644 | 644 | if ($dest != '') $result['destination'] = $dest; |
645 | 645 | } |
646 | 646 | $result['all'] = (array) $data; |