@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | / @param String $source source of data |
26 | 26 | */ |
27 | 27 | |
28 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
28 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
29 | 29 | date_default_timezone_set('UTC'); |
30 | - $date = date("Y-m-d H:i:s",time()); |
|
30 | + $date = date("Y-m-d H:i:s", time()); |
|
31 | 31 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
32 | 32 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
33 | 33 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | try { |
36 | 36 | $sth = $this->db->prepare($query); |
37 | 37 | $sth->execute($query_values); |
38 | - } catch(PDOException $e) { |
|
38 | + } catch (PDOException $e) { |
|
39 | 39 | return "error : ".$e->getMessage(); |
40 | 40 | } |
41 | 41 | if ($sth->fetchColumn() > 0) { |
42 | 42 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
43 | 43 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
44 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
44 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
45 | 45 | } elseif ($arrival_airport_time == '') { |
46 | 46 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
47 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
47 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
48 | 48 | } elseif ($departure_airport_time == '') { |
49 | 49 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
50 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
50 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
51 | 51 | } else { |
52 | 52 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
53 | 53 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
54 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
55 | 55 | } |
56 | 56 | try { |
57 | 57 | $sth = $this->db->prepare($query); |
58 | 58 | $sth->execute($query_values); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error : ".$e->getMessage(); |
61 | 61 | } |
62 | 62 | if ($sth->fetchColumn() == 0) { |
63 | 63 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
64 | 64 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
65 | 65 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
66 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
67 | 67 | } elseif ($arrival_airport_time == '') { |
68 | 68 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
69 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
69 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
70 | 70 | } elseif ($departure_airport_time == '') { |
71 | 71 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
72 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
72 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
73 | 73 | } else { |
74 | 74 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
75 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
75 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
76 | 76 | } |
77 | 77 | try { |
78 | 78 | $sth = $this->db->prepare($query); |
79 | 79 | $sth->execute($query_values); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
85 | 85 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
86 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
86 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
87 | 87 | try { |
88 | 88 | $sth = $this->db->prepare($query); |
89 | 89 | $sth->execute($query_values); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } else { |
95 | 95 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
96 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
96 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
97 | 97 | try { |
98 | 98 | $sth = $this->db->prepare($query); |
99 | 99 | $sth->execute($query_values); |
100 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | return "error : ".$e->getMessage(); |
102 | 102 | } |
103 | 103 | } |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | |
107 | 107 | public function getSchedule($ident) { |
108 | 108 | $Translation = new Translation($this->db); |
109 | - $operator = $Translation->checkTranslation($ident,false); |
|
109 | + $operator = $Translation->checkTranslation($ident, false); |
|
110 | 110 | if ($ident != $operator) { |
111 | 111 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
112 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
112 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
113 | 113 | } else { |
114 | 114 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
115 | 115 | $query_values = array(':ident' => $ident); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | try { |
118 | 118 | $sth = $this->db->prepare($query); |
119 | 119 | $sth->execute($query_values); |
120 | - } catch(PDOException $e) { |
|
120 | + } catch (PDOException $e) { |
|
121 | 121 | return "error : ".$e->getMessage(); |
122 | 122 | } |
123 | 123 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | try { |
142 | 142 | $sth = $this->db->prepare($query); |
143 | 143 | $sth->execute($query_values); |
144 | - } catch(PDOException $e) { |
|
144 | + } catch (PDOException $e) { |
|
145 | 145 | return "error : ".$e->getMessage(); |
146 | 146 | } |
147 | 147 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * @param String $carrier IATA code |
157 | 157 | * @return Flight departure and arrival airports and time |
158 | 158 | */ |
159 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
159 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
160 | 160 | $Common = new Common(); |
161 | 161 | $check_date = new Datetime($date); |
162 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
162 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
163 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
164 | 164 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
165 | 165 | $json = $Common->getData($url); |
166 | 166 | |
167 | 167 | $parsed_json = json_decode($json); |
168 | - if (property_exists($parsed_json,'errors') === false) { |
|
168 | + if (property_exists($parsed_json, 'errors') === false) { |
|
169 | 169 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
170 | 170 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
171 | 171 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
176 | 176 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
177 | 177 | |
178 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
178 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
179 | 179 | $DepartureAirportIata = $originiata[1]; |
180 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
180 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
181 | 181 | $ArrivalAirportIata = $destinationiata[1]; |
182 | 182 | |
183 | 183 | /* |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
187 | 187 | */ |
188 | 188 | |
189 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
189 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
190 | 190 | } else return array(); |
191 | 191 | } |
192 | 192 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | $Common = new Common(); |
202 | 202 | date_default_timezone_set($globalTimezone); |
203 | 203 | $check_date = new Datetime($date); |
204 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
204 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
205 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
206 | 206 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
207 | 207 | $json = $Common->getData($url); |
208 | 208 | $parsed_json = json_decode($json); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
215 | 215 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
216 | 216 | |
217 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
217 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
218 | 218 | } else return array(); |
219 | 219 | } |
220 | 220 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | */ |
226 | 226 | private function getRyanair($callsign) { |
227 | 227 | $Common = new Common(); |
228 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
228 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
229 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
230 | 230 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
231 | 231 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
232 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
233 | - $json = $Common->getData($url,'post',$post,$headers); |
|
232 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
233 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
234 | 234 | $parsed_json = json_decode($json); |
235 | 235 | if (isset($parsed_json->{'flightInfo'})) { |
236 | 236 | $flights = $parsed_json->{'flightInfo'}; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
240 | 240 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
241 | 241 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
242 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
242 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
243 | 243 | } else return array(); |
244 | 244 | } else return array(); |
245 | 245 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | */ |
252 | 252 | private function getSwiss($callsign) { |
253 | 253 | $Common = new Common(); |
254 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
254 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
255 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
256 | 256 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
257 | 257 | $json = $Common->getData($url); |
258 | 258 | $parsed_json = json_decode($json); |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
267 | 267 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
268 | 268 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
269 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
270 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
269 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
270 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
274 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
274 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
275 | 275 | } else return array(); |
276 | 276 | } else return array(); |
277 | 277 | } |
@@ -286,21 +286,21 @@ discard block |
||
286 | 286 | global $globalBritishAirwaysKey; |
287 | 287 | $Common = new Common(); |
288 | 288 | $check_date = new Datetime($date); |
289 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
289 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
290 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
291 | 291 | if ($globalBritishAirwaysKey == '') return array(); |
292 | 292 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
293 | 293 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
294 | - $json = $Common->getData($url,'get','',$headers); |
|
294 | + $json = $Common->getData($url, 'get', '', $headers); |
|
295 | 295 | if ($json == '') return array(); |
296 | 296 | $parsed_json = json_decode($json); |
297 | 297 | $flights = $parsed_json->{'FlightsResponse'}; |
298 | 298 | if (count($flights) > 0) { |
299 | 299 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
300 | 300 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
301 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
302 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
303 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
301 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
302 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
303 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
304 | 304 | } else return array(); |
305 | 305 | } |
306 | 306 | |
@@ -314,27 +314,27 @@ discard block |
||
314 | 314 | global $globalLufthansaKey; |
315 | 315 | $Common = new Common(); |
316 | 316 | $check_date = new Datetime($date); |
317 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
317 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
318 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
319 | 319 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
320 | 320 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
321 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
322 | - $data = $Common->getData($url,'post',$post); |
|
321 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
322 | + $data = $Common->getData($url, 'post', $post); |
|
323 | 323 | $parsed_data = json_decode($data); |
324 | 324 | if (!isset($parsed_data->{'access_token'})) return array(); |
325 | 325 | $token = $parsed_data->{'access_token'}; |
326 | 326 | |
327 | 327 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
328 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
329 | - $json = $Common->getData($url,'get','',$headers); |
|
328 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
329 | + $json = $Common->getData($url, 'get', '', $headers); |
|
330 | 330 | if ($json == '') return array(); |
331 | 331 | $parsed_json = json_decode($json); |
332 | 332 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
333 | 333 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
334 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
334 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
335 | 335 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
336 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
337 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
336 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
337 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
338 | 338 | } else return array(); |
339 | 339 | } |
340 | 340 | |
@@ -348,23 +348,23 @@ discard block |
||
348 | 348 | global $globalTransaviaKey; |
349 | 349 | $Common = new Common(); |
350 | 350 | $check_date = new Datetime($date); |
351 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
351 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
352 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
353 | 353 | if ($globalTransaviaKey == '') return array(); |
354 | 354 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
355 | 355 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
356 | 356 | $headers = array('apikey: '.$globalTransaviaKey); |
357 | - $json = $Common->getData($url,'get','',$headers); |
|
357 | + $json = $Common->getData($url, 'get', '', $headers); |
|
358 | 358 | //echo 'result : '.$json; |
359 | 359 | if ($json == '') return array(); |
360 | 360 | $parsed_json = json_decode($json); |
361 | 361 | |
362 | 362 | if (isset($parsed_json->{'data'}[0])) { |
363 | 363 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
364 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
364 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
365 | 365 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
366 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
367 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
366 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
367 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
368 | 368 | } else return array(); |
369 | 369 | } |
370 | 370 | |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function getTunisair($callsign) { |
377 | 377 | $Common = new Common(); |
378 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
378 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
379 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
380 | 380 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
381 | 381 | $data = $Common->getData($url); |
382 | 382 | $table = $Common->table2array($data); |
383 | 383 | foreach ($table as $flight) { |
384 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
385 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
384 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
385 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | return array(); |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | * @param String $callsign The callsign |
394 | 394 | * @return Flight departure and arrival airports and time |
395 | 395 | */ |
396 | - public function getVueling($callsign,$date = 'NOW') { |
|
396 | + public function getVueling($callsign, $date = 'NOW') { |
|
397 | 397 | $Common = new Common(); |
398 | 398 | $check_date = new Datetime($date); |
399 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
401 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
399 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
400 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
401 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
402 | 402 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
403 | 403 | $data = $Common->getData($url); |
404 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
404 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
405 | 405 | if ($data != '') { |
406 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
407 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
408 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
409 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
406 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
407 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
408 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
409 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
410 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
411 | 411 | else return array(); |
412 | 412 | } |
413 | 413 | return array(); |
@@ -421,27 +421,27 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function getIberia($callsign, $date = 'NOW') { |
423 | 423 | $Common = new Common(); |
424 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
424 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
425 | 425 | $check_date = new Datetime($date); |
426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
426 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
427 | 427 | $url = "https://www.iberia.com/web/flightDetail.do"; |
428 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
429 | - $data = $Common->getData($url,'post',$post); |
|
428 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
429 | + $data = $Common->getData($url, 'post', $post); |
|
430 | 430 | if ($data != '') { |
431 | 431 | $table = $Common->table2array($data); |
432 | 432 | //print_r($table); |
433 | 433 | if (count($table) > 0) { |
434 | 434 | $flight = $table; |
435 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
436 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
435 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
436 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
437 | 437 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
438 | 438 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
439 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
440 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
439 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
440 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
441 | 441 | if ($arrivalTime == 'Hora estimada de llegada') { |
442 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
444 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
442 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
443 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
444 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | return array(); |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | * @return Flight departure and arrival airports and time |
455 | 455 | */ |
456 | 456 | |
457 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
457 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
458 | 458 | $Common = new Common(); |
459 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
459 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
460 | 460 | $check_date = new Datetime($date); |
461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
461 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
462 | 462 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
463 | 463 | $data = $Common->getData($url); |
464 | 464 | if ($data != '') { |
@@ -467,13 +467,13 @@ discard block |
||
467 | 467 | $flight = $table; |
468 | 468 | //print_r($table); |
469 | 469 | if (isset($flight[25]) && isset($flight[29])) { |
470 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
471 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
470 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
471 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
472 | 472 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
473 | 473 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
474 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
475 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
476 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
474 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
475 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
476 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
477 | 477 | } else return array(); |
478 | 478 | } |
479 | 479 | |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | */ |
492 | 492 | private function getAlitalia($callsign, $date = 'NOW') { |
493 | 493 | $Common = new Common(); |
494 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
494 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
495 | 495 | $check_date = new Datetime($date); |
496 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
496 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
497 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
498 | 498 | $data = $Common->getData($url); |
499 | 499 | if ($data != '') { |
500 | 500 | $table = $Common->text2array($data); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | $ArrivalAirportIata = ''; |
503 | 503 | $departureTime = $table[4]; |
504 | 504 | $arrivalTime = $table[5]; |
505 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
505 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | */ |
515 | 515 | private function getBrussels($callsign, $date = 'NOW') { |
516 | 516 | $Common = new Common(); |
517 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
517 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
518 | 518 | $check_date = new Datetime($date); |
519 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
519 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
520 | 520 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
521 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
522 | 522 | $data = $Common->getData($url); |
523 | 523 | if ($data != '') { |
524 | 524 | //echo $data; |
525 | - $parsed_json = json_decode($data,true); |
|
525 | + $parsed_json = json_decode($data, true); |
|
526 | 526 | if (isset($parsed_json[0]['FromAirportCode'])) { |
527 | 527 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
528 | 528 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
529 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
530 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
531 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
529 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
530 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
531 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
@@ -605,21 +605,21 @@ discard block |
||
605 | 605 | */ |
606 | 606 | private function getFlyTap($callsign) { |
607 | 607 | $Common = new Common(); |
608 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
609 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
608 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
609 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
610 | 610 | //$check_date = new Datetime($date); |
611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
612 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
613 | - $data = $Common->getData($url,'post',$post); |
|
611 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
612 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
613 | + $data = $Common->getData($url, 'post', $post); |
|
614 | 614 | if ($data != '') { |
615 | 615 | $table = $Common->table2array($data); |
616 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
617 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
618 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
619 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
616 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
617 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
618 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
619 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
620 | 620 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
621 | 621 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
622 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
622 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
623 | 623 | } |
624 | 624 | return array(); |
625 | 625 | } |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | } |
642 | 642 | } |
643 | 643 | if ($airline_icao == '') return array(); |
644 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
645 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
644 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
645 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
646 | 646 | //$check_date = new Datetime($date); |
647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
647 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
648 | 648 | $data = $Common->getData($url); |
649 | 649 | if ($data != '') { |
650 | 650 | $table = $Common->table2array($data); |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | $darr = ''; |
655 | 655 | $ahour = ''; |
656 | 656 | $aarr = ''; |
657 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
657 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
658 | 658 | if ($n == 7) { |
659 | 659 | $departureTime = $dhour; |
660 | 660 | $arrivalTime = $ahour; |
661 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
662 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
663 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
661 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
662 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
663 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | } |
@@ -684,20 +684,20 @@ discard block |
||
684 | 684 | } |
685 | 685 | } |
686 | 686 | */ |
687 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
688 | - $url= "http://fr.flightaware.com/live/flight/".$callsign; |
|
687 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
688 | + $url = "http://fr.flightaware.com/live/flight/".$callsign; |
|
689 | 689 | //$check_date = new Datetime($date); |
690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
690 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
691 | 691 | $data = $Common->getData($url); |
692 | 692 | if ($data != '') { |
693 | 693 | $table = $Common->table2array($data); |
694 | 694 | if (isset($table[11][0])) { |
695 | - $departureTime = str_replace('h',':',substr($table[5][0],0,5)); |
|
696 | - $arrivalTime = str_replace('h',':',substr($table[5][1],0,5)); |
|
695 | + $departureTime = str_replace('h', ':', substr($table[5][0], 0, 5)); |
|
696 | + $arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5)); |
|
697 | 697 | echo $table[3][0]; |
698 | - sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata); |
|
699 | - sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata); |
|
700 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware'); |
|
698 | + sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata); |
|
699 | + sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata); |
|
700 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware'); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | return array(); |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | */ |
711 | 711 | public function getCostToTravel($callsign) { |
712 | 712 | $Common = new Common(); |
713 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
713 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
714 | 714 | //$check_date = new Datetime($date); |
715 | 715 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
716 | 716 | $data = $Common->getData($url); |
@@ -718,11 +718,11 @@ discard block |
||
718 | 718 | $table = $Common->table2array($data); |
719 | 719 | //print_r($table); |
720 | 720 | if (isset($table[11][1])) { |
721 | - $departureTime = substr($table[11][1],0,5); |
|
722 | - $arrivalTime = substr($table[17][1],0,5); |
|
723 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
724 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
725 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
721 | + $departureTime = substr($table[11][1], 0, 5); |
|
722 | + $arrivalTime = substr($table[17][1], 0, 5); |
|
723 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
724 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
725 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | return array(); |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @param String $date date we want flight number info |
735 | 735 | * @return Flight departure and arrival airports and time |
736 | 736 | */ |
737 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
737 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
738 | 738 | $Common = new Common(); |
739 | 739 | if (class_exists("DomDocument") === FALSE) return array(); |
740 | 740 | date_default_timezone_set('UTC'); |
741 | 741 | $check_date = new Datetime($date); |
742 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
743 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
744 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
742 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
743 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
744 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
745 | 745 | $data = $Common->getData($url); |
746 | 746 | $dom = new DomDocument(); |
747 | 747 | $dom->loadXML($data); |
@@ -749,11 +749,11 @@ discard block |
||
749 | 749 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
750 | 750 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
751 | 751 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
752 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
752 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
753 | 753 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
754 | 754 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
755 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
756 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
755 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
756 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
757 | 757 | } else return array(); |
758 | 758 | } |
759 | 759 | |
@@ -765,21 +765,21 @@ discard block |
||
765 | 765 | */ |
766 | 766 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
767 | 767 | $Common = new Common(); |
768 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
768 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
769 | 769 | $check_date = new Datetime($date); |
770 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
771 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
770 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
771 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
772 | 772 | $data = $Common->getData($url); |
773 | 773 | if ($data != '') { |
774 | 774 | $table = $Common->table2array($data); |
775 | 775 | $flight = $table; |
776 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
777 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
776 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
777 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
778 | 778 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
779 | 779 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
780 | 780 | $departureTime = $flight[5][1]; |
781 | 781 | $arrivalTime = $flight[23][1]; |
782 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
782 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -790,16 +790,16 @@ discard block |
||
790 | 790 | * @param String $carrier airline code |
791 | 791 | * @return Flight departure and arrival airports and time |
792 | 792 | */ |
793 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
793 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
794 | 794 | $Common = new Common(); |
795 | 795 | date_default_timezone_set('UTC'); |
796 | 796 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
797 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
797 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
798 | 798 | $check_date = new Datetime($date); |
799 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
800 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
801 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
802 | - $data = $Common->getData($url,'post',$post); |
|
799 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
800 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
801 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
802 | + $data = $Common->getData($url, 'post', $post); |
|
803 | 803 | //echo $data; |
804 | 804 | $DepartureAirportIata = ''; |
805 | 805 | $ArrivalAirportIata = ''; |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
813 | 813 | else $departureAirport = ''; |
814 | 814 | } else return array(); |
815 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
816 | - $data = $Common->getData($url,'post',$post); |
|
815 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
816 | + $data = $Common->getData($url, 'post', $post); |
|
817 | 817 | if ($data != '') { |
818 | 818 | $table = $Common->table2array($data); |
819 | 819 | $flight = $table; |
@@ -841,13 +841,13 @@ discard block |
||
841 | 841 | } |
842 | 842 | } |
843 | 843 | if (isset($DepartureAirportIata)) { |
844 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
844 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
845 | 845 | } else return array(); |
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | 849 | |
850 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
850 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
851 | 851 | global $globalSchedulesSources, $globalSchedulesFetch; |
852 | 852 | //$Common = new Common(); |
853 | 853 | if (!$globalSchedulesFetch) return array(); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | // Brussels Airlines |
918 | 918 | case "BEL": |
919 | 919 | case "SN": |
920 | - return $this->getBrussels($ident,$date); |
|
920 | + return $this->getBrussels($ident, $date); |
|
921 | 921 | /* |
922 | 922 | // Copa Airlines |
923 | 923 | case "CMP": |
@@ -1002,17 +1002,17 @@ discard block |
||
1002 | 1002 | // Air France |
1003 | 1003 | case "AF": |
1004 | 1004 | case "AFR": |
1005 | - return $this->getAirFrance($ident,$date,'AF'); |
|
1005 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
1006 | 1006 | // HOP |
1007 | 1007 | case "A5": |
1008 | 1008 | case "HOP": |
1009 | - return $this->getAirFrance($ident,$date,'A5'); |
|
1009 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
1010 | 1010 | // EasyJet |
1011 | 1011 | case "U2": |
1012 | 1012 | case "DS": |
1013 | 1013 | case "EZY": |
1014 | 1014 | case "EZS": |
1015 | - return $this->getEasyJet($ident,$date); |
|
1015 | + return $this->getEasyJet($ident, $date); |
|
1016 | 1016 | // Ryanair |
1017 | 1017 | case "FR": |
1018 | 1018 | case "RYR": |
@@ -1062,25 +1062,25 @@ discard block |
||
1062 | 1062 | return $this->getIberia($ident); |
1063 | 1063 | // Vietnam Airlines |
1064 | 1064 | case "HVN": |
1065 | - return $this->getVietnamAirlines($ident,$date); |
|
1065 | + return $this->getVietnamAirlines($ident, $date); |
|
1066 | 1066 | // Air Berlin |
1067 | 1067 | case "AB": |
1068 | 1068 | case "BER": |
1069 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
1069 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
1070 | 1070 | // NIKI |
1071 | 1071 | case "HG": |
1072 | 1072 | case "NLY": |
1073 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
1073 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
1074 | 1074 | // BelAir |
1075 | 1075 | case "4T": |
1076 | 1076 | case "BHP": |
1077 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
1077 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
1078 | 1078 | default: |
1079 | 1079 | // Randomly use a generic function to get hours |
1080 | 1080 | if (strlen($airline_icao) == 2) { |
1081 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1081 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1082 | 1082 | if (count($globalSchedulesSources) > 0) { |
1083 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
1083 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
1084 | 1084 | $source = $globalSchedulesSources[$rand]; |
1085 | 1085 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
1086 | 1086 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | try { |
983 | 983 | $sth = $this->db->prepare($query); |
984 | 984 | $sth->execute($query_values); |
985 | - } catch(PDOException $e) { |
|
985 | + } catch (PDOException $e) { |
|
986 | 986 | echo "error : ".$e->getMessage(); |
987 | 987 | } |
988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1000,19 +1000,19 @@ discard block |
||
1000 | 1000 | try { |
1001 | 1001 | $sth = $this->db->prepare($query); |
1002 | 1002 | $sth->execute($query_values); |
1003 | - } catch(PDOException $e) { |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | echo "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1007 | 1007 | return $all; |
1008 | 1008 | } |
1009 | 1009 | public function getAllNOTAMtext() { |
1010 | - $query = 'SELECT full_notam FROM notam'; |
|
1010 | + $query = 'SELECT full_notam FROM notam'; |
|
1011 | 1011 | $query_values = array(); |
1012 | 1012 | try { |
1013 | 1013 | $sth = $this->db->prepare($query); |
1014 | 1014 | $sth->execute($query_values); |
1015 | - } catch(PDOException $e) { |
|
1015 | + } catch (PDOException $e) { |
|
1016 | 1016 | echo "error : ".$e->getMessage(); |
1017 | 1017 | } |
1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1021,13 +1021,13 @@ discard block |
||
1021 | 1021 | public function createNOTAMtextFile($filename) { |
1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); |
1023 | 1023 | $notamtext = ''; |
1024 | - foreach($allnotam_result as $notam) { |
|
1024 | + foreach ($allnotam_result as $notam) { |
|
1025 | 1025 | $notamtext .= '%%'."\n"; |
1026 | 1026 | $notamtext .= $notam['full_notam']; |
1027 | 1027 | $notamtext .= "\n".'%%'."\n"; |
1028 | 1028 | } |
1029 | 1029 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
1030 | - file_put_contents($filename,$notamtext); |
|
1030 | + file_put_contents($filename, $notamtext); |
|
1031 | 1031 | } |
1032 | 1032 | public function parseNOTAMtextFile($filename) { |
1033 | 1033 | $data = file_get_contents($filename); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | try { |
1049 | 1049 | $sth = $this->db->prepare($query); |
1050 | 1050 | $sth->execute($query_values); |
1051 | - } catch(PDOException $e) { |
|
1051 | + } catch (PDOException $e) { |
|
1052 | 1052 | echo "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | public function getAllNOTAMbyCoord($coord) { |
1058 | 1058 | global $globalDBdriver; |
1059 | 1059 | if (is_array($coord)) { |
1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1064 | 1064 | if ($minlat > $maxlat) { |
1065 | 1065 | $tmplat = $minlat; |
1066 | 1066 | $minlat = $maxlat; |
@@ -1082,19 +1082,19 @@ discard block |
||
1082 | 1082 | try { |
1083 | 1083 | $sth = $this->db->prepare($query); |
1084 | 1084 | $sth->execute($query_values); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | echo "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1089 | 1089 | return $all; |
1090 | 1090 | } |
1091 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
1091 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
1092 | 1092 | global $globalDBdriver; |
1093 | 1093 | if (is_array($coord)) { |
1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1098 | 1098 | } else return array(); |
1099 | 1099 | if ($globalDBdriver == 'mysql') { |
1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | try { |
1107 | 1107 | $sth = $this->db->prepare($query); |
1108 | 1108 | $sth->execute($query_values); |
1109 | - } catch(PDOException $e) { |
|
1109 | + } catch (PDOException $e) { |
|
1110 | 1110 | echo "error : ".$e->getMessage(); |
1111 | 1111 | } |
1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | try { |
1119 | 1119 | $sth = $this->db->prepare($query); |
1120 | 1120 | $sth->execute($query_values); |
1121 | - } catch(PDOException $e) { |
|
1121 | + } catch (PDOException $e) { |
|
1122 | 1122 | return "error : ".$e->getMessage(); |
1123 | 1123 | } |
1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | else return array(); |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
|
1129 | + public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { |
|
1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
1131 | - $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
|
1131 | + $query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); |
|
1132 | 1132 | try { |
1133 | 1133 | $sth = $this->db->prepare($query); |
1134 | 1134 | $sth->execute($query_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | try { |
1144 | 1144 | $sth = $this->db->prepare($query); |
1145 | 1145 | $sth->execute($query_values); |
1146 | - } catch(PDOException $e) { |
|
1146 | + } catch (PDOException $e) { |
|
1147 | 1147 | return "error : ".$e->getMessage(); |
1148 | 1148 | } |
1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $sth = $this->db->prepare($query); |
1160 | 1160 | $sth->execute($query_values); |
1161 | - } catch(PDOException $e) { |
|
1161 | + } catch (PDOException $e) { |
|
1162 | 1162 | return "error : ".$e->getMessage(); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | try { |
1169 | 1169 | $sth = $this->db->prepare($query); |
1170 | 1170 | $sth->execute($query_values); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | try { |
1178 | 1178 | $sth = $this->db->prepare($query); |
1179 | 1179 | $sth->execute(); |
1180 | - } catch(PDOException $e) { |
|
1180 | + } catch (PDOException $e) { |
|
1181 | 1181 | return "error : ".$e->getMessage(); |
1182 | 1182 | } |
1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute(); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | return "error : ".$e->getMessage(); |
1191 | 1191 | } |
1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
1194 | 1194 | public function updateNOTAM() { |
1195 | 1195 | global $globalNOTAMAirports; |
1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
1198 | - $airport_icao = implode(',',$airport); |
|
1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
1198 | + $airport_icao = implode(',', $airport); |
|
1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
1200 | 1200 | if (count($alldata) > 0) { |
1201 | 1201 | foreach ($alldata as $initial_data) { |
1202 | 1202 | $data = $this->parse($initial_data); |
1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | foreach ($alldata as $initial_data) { |
1215 | 1215 | $data = $this->parse($initial_data); |
1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1223,12 +1223,12 @@ discard block |
||
1223 | 1223 | global $globalTransaction; |
1224 | 1224 | $Spotter = new Spotter($this->db); |
1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); |
1226 | - foreach (array_chunk($allairports,20) as $airport) { |
|
1226 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
1227 | 1227 | $airports_icao = array(); |
1228 | - foreach($airport as $icao) { |
|
1228 | + foreach ($airport as $icao) { |
|
1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
1230 | 1230 | } |
1231 | - $airport_icao = implode(',',$airports_icao); |
|
1231 | + $airport_icao = implode(',', $airports_icao); |
|
1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); |
1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); |
1234 | 1234 | if (count($alldata) > 0) { |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | if (count($notamref) == 0) { |
1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1245 | 1245 | } |
1246 | 1246 | } |
1247 | 1247 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | date_default_timezone_set("UTC"); |
1256 | 1256 | $Common = new Common(); |
1257 | 1257 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
1258 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1258 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1259 | 1259 | $data = $Common->getData($url); |
1260 | 1260 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1261 | 1261 | //print_r($matches); |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | $result['permanent'] = ''; |
1273 | 1273 | $result['date_begin'] = NULL; |
1274 | 1274 | $result['date_end'] = NULL; |
1275 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
1275 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
1276 | 1276 | //echo $data."\n"; |
1277 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
1277 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
1278 | 1278 | //print_r($data); |
1279 | 1279 | $q = false; |
1280 | 1280 | $a = false; |
@@ -1283,9 +1283,9 @@ discard block |
||
1283 | 1283 | $e = false; |
1284 | 1284 | foreach ($data as $line) { |
1285 | 1285 | $line = trim($line); |
1286 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
1287 | - $line = str_replace(' ','',$line); |
|
1288 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
1286 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
1287 | + $line = str_replace(' ', '', $line); |
|
1288 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
1289 | 1289 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
1290 | 1290 | //print_r($matches); |
1291 | 1291 | $result['fir'] = $matches[1]; |
@@ -1331,9 +1331,9 @@ discard block |
||
1331 | 1331 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
1332 | 1332 | $result['lower_limit'] = $matches[6]; |
1333 | 1333 | $result['upper_limit'] = $matches[7]; |
1334 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
1334 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
1335 | 1335 | if ($matches[9] == 'S') $latitude = -$latitude; |
1336 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
1336 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
1337 | 1337 | if ($matches[11] == 'W') $longitude = -$longitude; |
1338 | 1338 | $result['latitude'] = $latitude; |
1339 | 1339 | $result['longitude'] = $longitude; |
@@ -1345,24 +1345,24 @@ discard block |
||
1345 | 1345 | echo "Can't parse : ".$line."\n"; |
1346 | 1346 | } |
1347 | 1347 | } |
1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
1348 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
1349 | 1349 | $result['icao'] = $matches[2]; |
1350 | 1350 | $a = true; |
1351 | 1351 | } |
1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
1352 | + elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) { |
|
1353 | 1353 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
1354 | 1354 | else $year = '20'.$matches[2]; |
1355 | 1355 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1356 | 1356 | $b = true; |
1357 | 1357 | } |
1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
1358 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) { |
|
1359 | 1359 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1360 | 1360 | else $year = '20'.$matches[2]; |
1361 | 1361 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1362 | 1362 | $result['permanent'] = 0; |
1363 | 1363 | $c = true; |
1364 | 1364 | } |
1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1365 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1366 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1367 | 1367 | else $year = '20'.$matches[2]; |
1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | else $result['permanent'] = 0; |
1373 | 1373 | $c = true; |
1374 | 1374 | } |
1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1375 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1376 | 1376 | $result['date_end'] = '2030/12/20 12:00'; |
1377 | 1377 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
1378 | 1378 | else $result['estimated'] = 0; |
@@ -1380,20 +1380,20 @@ discard block |
||
1380 | 1380 | else $result['permanent'] = 0; |
1381 | 1381 | $c = true; |
1382 | 1382 | } |
1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
1383 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
1384 | 1384 | $rtext = array(); |
1385 | - $text = explode(' ',$matches[2]); |
|
1385 | + $text = explode(' ', $matches[2]); |
|
1386 | 1386 | foreach ($text as $word) { |
1387 | 1387 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1388 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
1389 | 1389 | else $rtext[] = $word; |
1390 | 1390 | } |
1391 | - $result['text'] = implode(' ',$rtext); |
|
1391 | + $result['text'] = implode(' ', $rtext); |
|
1392 | 1392 | $e = true; |
1393 | 1393 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
1394 | 1394 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
1395 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
1396 | - $text = explode(' ',$line); |
|
1395 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
1396 | + $text = explode(' ', $line); |
|
1397 | 1397 | $result['ref'] = $text[0]; |
1398 | 1398 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
1399 | 1399 | if ($matches[1] == 'NOTAMC') { |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | require_once('require/class.Satellite.php'); |
6 | 6 | |
7 | -$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING); |
|
7 | +$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING); |
|
8 | 8 | if ($trackident != '') { |
9 | 9 | require_once('require/class.SpotterLive.php'); |
10 | 10 | $SpotterLive = new SpotterLive(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident); |
15 | 15 | header('Location: '.$globalURL.'/flightid/'.$spotterid); |
16 | 16 | } else { |
17 | - setcookie('MapTrack',$resulttrackident[0]['flightaware_id']); |
|
17 | + setcookie('MapTrack', $resulttrackident[0]['flightaware_id']); |
|
18 | 18 | } |
19 | 19 | } else { |
20 | 20 | unset($_COOKIE['MapTrack']); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | <div class="form-group"> |
195 | 195 | <label>From (UTC):</label> |
196 | 196 | <div class='input-group date' id='datetimepicker1'> |
197 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
197 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a", $_COOKIE['archive_begin']); ?>" required /> |
|
198 | 198 | <span class="input-group-addon"> |
199 | 199 | <span class="glyphicon glyphicon-calendar"></span> |
200 | 200 | </span> |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | <div class="form-group"> |
204 | 204 | <label>To (UTC):</label> |
205 | 205 | <div class='input-group date' id='datetimepicker2'> |
206 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
206 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a", $_COOKIE['archive_end']); ?>" /> |
|
207 | 207 | <span class="input-group-addon"> |
208 | 208 | <span class="glyphicon glyphicon-calendar"></span> |
209 | 209 | </span> |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | <li><?php echo _("Type of Terrain:"); ?> |
328 | 328 | <select class="selectpicker" onchange="terrainType(this);"> |
329 | 329 | <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
330 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
331 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
332 | - <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option> |
|
330 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option> |
|
331 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option> |
|
332 | + <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected'; ?>>ArticDEM</option> |
|
333 | 333 | </select> |
334 | 334 | </li> |
335 | 335 | <?php |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
366 | 366 | <?php |
367 | 367 | } |
368 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
368 | + if (time() > mktime(0, 0, 0, 12, 1, date("Y")) && time() < mktime(0, 0, 0, 12, 31, date("Y"))) { |
|
369 | 369 | ?> |
370 | 370 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
371 | 371 | <?php |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | $Spotter = new Spotter(); |
542 | 542 | $allairlinenames = $Spotter->getAllAirlineNames(); |
543 | 543 | } |
544 | - foreach($allairlinenames as $airline) { |
|
544 | + foreach ($allairlinenames as $airline) { |
|
545 | 545 | $airline_name = $airline['airline_name']; |
546 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
547 | - if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) { |
|
546 | + if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...'; |
|
547 | + if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['filter_Airlines']))) { |
|
548 | 548 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
549 | 549 | } else { |
550 | 550 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
564 | 564 | <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
565 | 565 | <?php |
566 | - foreach($allalliancenames as $alliance) { |
|
566 | + foreach ($allalliancenames as $alliance) { |
|
567 | 567 | $alliance_name = $alliance['alliance']; |
568 | 568 | if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] == $alliance_name) { |
569 | 569 | echo '<option value="'.$alliance_name.'" selected>'.$alliance_name.'</option>'; |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | */ |
600 | 600 | $Source = new Source(); |
601 | 601 | $datasource = $Source->getLocationInfoByType('gs'); |
602 | - foreach($datasource as $src) { |
|
603 | - if (isset($_COOKIE['filter_Sources']) && in_array($src['name'],explode(',',$_COOKIE['filter_Sources']))) { |
|
602 | + foreach ($datasource as $src) { |
|
603 | + if (isset($_COOKIE['filter_Sources']) && in_array($src['name'], explode(',', $_COOKIE['filter_Sources']))) { |
|
604 | 604 | echo '<option value="'.$src['name'].'" selected>'.$src['name'].'</option>'; |
605 | 605 | } else { |
606 | 606 | echo '<option value="'.$src['name'].'">'.$src['name'].'</option>'; |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
680 | 680 | else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
681 | 681 | |
682 | - if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
|
682 | + if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) { |
|
683 | 683 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
684 | 684 | } else { |
685 | 685 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | $Source = new Source(); |
6 | 6 | |
7 | 7 | if (isset($_GET['sourceid'])) { |
8 | - $sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT); |
|
8 | + $sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT); |
|
9 | 9 | $source_data = $Source->getLocationInfoById($sourceid); |
10 | 10 | if (isset($source_data[0])) { |
11 | 11 | ?> |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | print '</div>'; |
38 | 38 | |
39 | 39 | if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; |
40 | -if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
41 | -print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],4).', '.round($spotter_item['longitude'],4).'</div>'; |
|
40 | +if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
41 | +print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 4).', '.round($spotter_item['longitude'], 4).'</div>'; |
|
42 | 42 | /* |
43 | 43 | if ($spotter_item['atc_range'] > 0) { |
44 | 44 | print '<div><span>'._("Range").'</span>'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | */ |
49 | 49 | if ($spotter_item['type'] == 'wx') { |
50 | - $weather = json_decode($spotter_item['description'],true); |
|
50 | + $weather = json_decode($spotter_item['description'], true); |
|
51 | 51 | //print_r($weather); |
52 | 52 | if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; |
53 | 53 | if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>'; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | try { |
17 | 17 | $sth = $this->db->prepare($query); |
18 | 18 | $sth->execute($query_values); |
19 | - } catch(PDOException $e) { |
|
19 | + } catch (PDOException $e) { |
|
20 | 20 | return "error : ".$e->getMessage(); |
21 | 21 | } |
22 | 22 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | try { |
30 | 30 | $sth = $this->db->prepare($query); |
31 | 31 | $sth->execute($query_values); |
32 | - } catch(PDOException $e) { |
|
32 | + } catch (PDOException $e) { |
|
33 | 33 | return "error : ".$e->getMessage(); |
34 | 34 | } |
35 | 35 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
36 | 36 | return $all; |
37 | 37 | } |
38 | 38 | |
39 | - public function getLocationInfobyNameType($name,$type) { |
|
39 | + public function getLocationInfobyNameType($name, $type) { |
|
40 | 40 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
41 | - $query_values = array(':name' => $name,':type' => $type); |
|
41 | + $query_values = array(':name' => $name, ':type' => $type); |
|
42 | 42 | try { |
43 | 43 | $sth = $this->db->prepare($query); |
44 | 44 | $sth->execute($query_values); |
45 | - } catch(PDOException $e) { |
|
45 | + } catch (PDOException $e) { |
|
46 | 46 | return "error : ".$e->getMessage(); |
47 | 47 | } |
48 | 48 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | try { |
56 | 56 | $sth = $this->db->prepare($query); |
57 | 57 | $sth->execute($query_values); |
58 | - } catch(PDOException $e) { |
|
58 | + } catch (PDOException $e) { |
|
59 | 59 | return "error : ".$e->getMessage(); |
60 | 60 | } |
61 | 61 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | public function getLocationInfoByType($type, $coord = array(), $limit = false) { |
66 | 66 | $query = "SELECT * FROM source_location WHERE type = :type"; |
67 | 67 | if (is_array($coord) && !empty($coord)) { |
68 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
69 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
70 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
71 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
68 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
69 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
70 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
71 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
72 | 72 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
73 | 73 | } |
74 | 74 | $query .= " ORDER BY last_seen DESC"; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | try { |
78 | 78 | $sth = $this->db->prepare($query); |
79 | 79 | $sth->execute($query_values); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | try { |
91 | 91 | $sth = $this->db->prepare($query); |
92 | 92 | $sth->execute($query_values); |
93 | - } catch(PDOException $e) { |
|
93 | + } catch (PDOException $e) { |
|
94 | 94 | return "error : ".$e->getMessage(); |
95 | 95 | } |
96 | 96 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -103,56 +103,56 @@ discard block |
||
103 | 103 | try { |
104 | 104 | $sth = $this->db->prepare($query); |
105 | 105 | $sth->execute($query_values); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | 109 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
110 | 110 | return $all; |
111 | 111 | } |
112 | 112 | |
113 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
113 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
114 | 114 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
115 | 115 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
116 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
116 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
117 | 117 | try { |
118 | 118 | $sth = $this->db->prepare($query); |
119 | 119 | $sth->execute($query_values); |
120 | - } catch(PDOException $e) { |
|
120 | + } catch (PDOException $e) { |
|
121 | 121 | echo "error : ".$e->getMessage(); |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
125 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
126 | 126 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
127 | 127 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
128 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
128 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
129 | 129 | try { |
130 | 130 | $sth = $this->db->prepare($query); |
131 | 131 | $sth->execute($query_values); |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | return "error : ".$e->getMessage(); |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
137 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
138 | 138 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
139 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
139 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
140 | 140 | try { |
141 | 141 | $sth = $this->db->prepare($query); |
142 | 142 | $sth->execute($query_values); |
143 | - } catch(PDOException $e) { |
|
143 | + } catch (PDOException $e) { |
|
144 | 144 | return "error : ".$e->getMessage(); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
148 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
149 | 149 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
150 | 150 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
151 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
151 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
152 | 152 | try { |
153 | 153 | $sth = $this->db->prepare($query); |
154 | 154 | $sth->execute($query_values); |
155 | - } catch(PDOException $e) { |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | echo "error : ".$e->getMessage(); |
157 | 157 | } |
158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | try { |
164 | 164 | $sth = $this->db->prepare($query); |
165 | 165 | $sth->execute($query_values); |
166 | - } catch(PDOException $e) { |
|
166 | + } catch (PDOException $e) { |
|
167 | 167 | return "error : ".$e->getMessage(); |
168 | 168 | } |
169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | try { |
175 | 175 | $sth = $this->db->prepare($query); |
176 | 176 | $sth->execute($query_values); |
177 | - } catch(PDOException $e) { |
|
177 | + } catch (PDOException $e) { |
|
178 | 178 | return "error : ".$e->getMessage(); |
179 | 179 | } |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | try { |
186 | 186 | $sth = $this->db->prepare($query); |
187 | 187 | $sth->execute($query_values); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | try { |
196 | 196 | $sth = $this->db->prepare($query); |
197 | 197 | $sth->execute(); |
198 | - } catch(PDOException $e) { |
|
198 | + } catch (PDOException $e) { |
|
199 | 199 | return "error : ".$e->getMessage(); |
200 | 200 | } |
201 | 201 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(array(':type' => $type)); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | return "error"; |
229 | 229 | } |
230 | 230 | return "success"; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | require_once('require/class.Language.php'); |
4 | 4 | require_once('require/class.Translation.php'); |
5 | 5 | $type = ''; |
6 | -$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
6 | +$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
7 | 7 | if (isset($_GET['marine'])) { |
8 | 8 | require_once('require/class.Marine.php'); |
9 | 9 | require_once('require/class.MarineLive.php'); |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | $page_url = $globalURL.'/ident/'.$_GET['ident']; |
31 | 31 | } |
32 | 32 | |
33 | -if (!isset($_GET['ident'])){ |
|
33 | +if (!isset($_GET['ident'])) { |
|
34 | 34 | header('Location: '.$globalURL.''); |
35 | 35 | } else { |
36 | 36 | $Translation = new Translation(); |
37 | 37 | //calculuation for the pagination |
38 | - if(!isset($_GET['limit'])) |
|
38 | + if (!isset($_GET['limit'])) |
|
39 | 39 | { |
40 | 40 | $limit_start = 0; |
41 | 41 | $limit_end = 25; |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | $limit_previous_1 = $limit_start - $absolute_difference; |
55 | 55 | $limit_previous_2 = $limit_end - $absolute_difference; |
56 | 56 | |
57 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
57 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
58 | 58 | if ($type == 'aircraft') { |
59 | 59 | if ($sort != '') |
60 | 60 | { |
61 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
61 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
62 | 62 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
63 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
63 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
66 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
67 | 67 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
68 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
68 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | if (empty($spotter_array)) { |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | $ident = $new_ident; |
75 | 75 | if ($sort != '') |
76 | 76 | { |
77 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
77 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
78 | 78 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
79 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
79 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
80 | 80 | } |
81 | 81 | } else { |
82 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
82 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
83 | 83 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
84 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
84 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -89,34 +89,34 @@ discard block |
||
89 | 89 | } elseif ($type == 'marine') { |
90 | 90 | if ($sort != '') |
91 | 91 | { |
92 | - $spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
92 | + $spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
93 | 93 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
94 | - $spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
94 | + $spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | - $spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
97 | + $spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
98 | 98 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
99 | - $spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
99 | + $spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } elseif ($type == 'tracker') { |
103 | 103 | if ($sort != '') |
104 | 104 | { |
105 | - $spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
105 | + $spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
106 | 106 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
107 | - $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
107 | + $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
108 | 108 | } |
109 | 109 | } else { |
110 | - $spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
110 | + $spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
111 | 111 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
112 | - $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
112 | + $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | if (!empty($spotter_array)) |
118 | 118 | { |
119 | - $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
|
119 | + $title = sprintf(_("Detailed View for %s"), $spotter_array[0]['ident']); |
|
120 | 120 | $ident = $spotter_array[0]['ident']; |
121 | 121 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
122 | 122 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $altitude_data = ''; |
136 | 136 | $hour_data = ''; |
137 | 137 | $speed_data = ''; |
138 | - foreach($all_data as $data) |
|
138 | + foreach ($all_data as $data) |
|
139 | 139 | { |
140 | 140 | $hour_data .= '"'.$data['date'].'",'; |
141 | 141 | if (isset($data['real_altitude']) && $data['real_altitude'] != '') { |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | $speed_data .= $speed.','; |
164 | 164 | } |
165 | 165 | $hour_data = "['x',".substr($hour_data, 0, -1)."]"; |
166 | - $altitude_data = "['altitude',".substr($altitude_data,0,-1)."]"; |
|
167 | - $speed_data = "['speed',".substr($speed_data,0,-1)."]"; |
|
166 | + $altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]"; |
|
167 | + $speed_data = "['speed',".substr($speed_data, 0, -1)."]"; |
|
168 | 168 | print 'c3.generate({ |
169 | 169 | bindto: "#chart", |
170 | 170 | data: { |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | if ($type == 'aircraft') include('ident-sub-menu.php'); |
210 | 210 | print '<div class="table column">'; |
211 | - if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
212 | - elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
213 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
211 | + if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
212 | + elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
213 | + elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
214 | 214 | |
215 | 215 | include('table-output.php'); |
216 | 216 | print '<div class="pagination">'; |
@@ -14,82 +14,82 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
35 | 35 | if ($flt['airlines'][0] != '') { |
36 | 36 | if (isset($flt['source'])) { |
37 | - $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 | + $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"; |
|
38 | 38 | } else { |
39 | - $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 | + $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"; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
43 | 43 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
44 | 44 | if (isset($flt['source'])) { |
45 | - $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 | + $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"; |
|
46 | 46 | } else { |
47 | - $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 | + $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"; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
51 | 51 | if (isset($flt['source'])) { |
52 | - $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 | + $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"; |
|
53 | 53 | } else { |
54 | - $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 | + $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"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
58 | 58 | if (isset($flt['source'])) { |
59 | - $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 | + $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"; |
|
60 | 60 | } else { |
61 | - $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 | + $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"; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | 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']))) { |
65 | 65 | if (isset($flt['source'])) { |
66 | - $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 | + $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"; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
71 | 71 | if ($filter['airlines'][0] != '') { |
72 | - $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 | + $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"; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
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 | 82 | if (count($filter['source']) == 1) { |
83 | 83 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
84 | 84 | } else { |
85 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
85 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
89 | 89 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
90 | 90 | } |
91 | 91 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
92 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
92 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
93 | 93 | } |
94 | 94 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
95 | 95 | $filter_query_date = ''; |
@@ -114,41 +114,41 @@ discard block |
||
114 | 114 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
115 | 115 | } |
116 | 116 | } |
117 | - $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"; |
|
117 | + $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"; |
|
118 | 118 | } |
119 | 119 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
120 | 120 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
121 | 121 | if ($filter_query_where != '') { |
122 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
122 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
123 | 123 | } |
124 | 124 | $filter_query = $filter_query_join.$filter_query_where; |
125 | 125 | return $filter_query; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Spotter_archive |
129 | - 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
129 | + 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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
130 | 130 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
131 | 131 | if ($over_country == '') { |
132 | 132 | $Spotter = new Spotter($this->db); |
133 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
133 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
134 | 134 | if (!empty($data_country)) $country = $data_country['iso2']; |
135 | 135 | else $country = ''; |
136 | 136 | } else $country = $over_country; |
137 | - if ($airline_type === NULL) $airline_type =''; |
|
137 | + if ($airline_type === NULL) $airline_type = ''; |
|
138 | 138 | |
139 | 139 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
140 | 140 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
141 | 141 | |
142 | 142 | // Route is not added in spotter_archive |
143 | - $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,real_altitude) |
|
143 | + $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,real_altitude) |
|
144 | 144 | 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,:real_altitude)"; |
145 | 145 | |
146 | - $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,':real_altitude' => $real_altitude); |
|
146 | + $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, ':real_altitude' => $real_altitude); |
|
147 | 147 | try { |
148 | 148 | $sth = $this->db->prepare($query); |
149 | 149 | $sth->execute($query_values); |
150 | 150 | $sth->closeCursor(); |
151 | - } catch(PDOException $e) { |
|
151 | + } catch (PDOException $e) { |
|
152 | 152 | return "error : ".$e->getMessage(); |
153 | 153 | } |
154 | 154 | return "success"; |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | |
169 | 169 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
170 | 170 | //$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"; |
171 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
171 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
172 | 172 | |
173 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
173 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
174 | 174 | |
175 | 175 | return $spotter_array; |
176 | 176 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
190 | 190 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
191 | 191 | //$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"; |
192 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
192 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
193 | 193 | |
194 | 194 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
195 | 195 | /* |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
204 | 204 | */ |
205 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
205 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
206 | 206 | |
207 | 207 | return $spotter_array; |
208 | 208 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | { |
218 | 218 | date_default_timezone_set('UTC'); |
219 | 219 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
220 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
220 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
221 | 221 | |
222 | 222 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
223 | 223 | |
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(array(':id' => $id)); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo $e->getMessage(); |
229 | 229 | die; |
230 | 230 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | { |
244 | 244 | date_default_timezone_set('UTC'); |
245 | 245 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
246 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
246 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
247 | 247 | |
248 | 248 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
249 | 249 | |
250 | 250 | try { |
251 | 251 | $sth = $this->db->prepare($query); |
252 | 252 | $sth->execute(array(':id' => $id)); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | echo $e->getMessage(); |
255 | 255 | die; |
256 | 256 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | date_default_timezone_set('UTC'); |
273 | 273 | |
274 | 274 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
275 | - $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"; |
|
275 | + $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"; |
|
276 | 276 | |
277 | 277 | try { |
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute(array(':ident' => $ident)); |
280 | - } catch(PDOException $e) { |
|
280 | + } catch (PDOException $e) { |
|
281 | 281 | echo $e->getMessage(); |
282 | 282 | die; |
283 | 283 | } |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | date_default_timezone_set('UTC'); |
299 | 299 | |
300 | 300 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
301 | - $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"; |
|
301 | + $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"; |
|
302 | 302 | |
303 | 303 | try { |
304 | 304 | $sth = $this->db->prepare($query); |
305 | 305 | $sth->execute(array(':id' => $id)); |
306 | - } catch(PDOException $e) { |
|
306 | + } catch (PDOException $e) { |
|
307 | 307 | echo $e->getMessage(); |
308 | 308 | die; |
309 | 309 | } |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | { |
323 | 323 | date_default_timezone_set('UTC'); |
324 | 324 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
325 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
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 | } |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | { |
345 | 345 | date_default_timezone_set('UTC'); |
346 | 346 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
347 | - $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"; |
|
347 | + $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"; |
|
348 | 348 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
349 | 349 | try { |
350 | 350 | $sth = $this->db->prepare($query); |
351 | 351 | $sth->execute(array(':ident' => $ident)); |
352 | - } catch(PDOException $e) { |
|
352 | + } catch (PDOException $e) { |
|
353 | 353 | echo $e->getMessage(); |
354 | 354 | die; |
355 | 355 | } |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | * @return Array the spotter information |
366 | 366 | * |
367 | 367 | */ |
368 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
368 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
369 | 369 | { |
370 | 370 | $Spotter = new Spotter($this->db); |
371 | 371 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
372 | - $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"; |
|
373 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
372 | + $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"; |
|
373 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
374 | 374 | return $spotter_array; |
375 | 375 | } |
376 | 376 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | try { |
386 | 386 | $sth = $this->db->prepare($query); |
387 | 387 | $sth->execute(); |
388 | - } catch(PDOException $e) { |
|
388 | + } catch (PDOException $e) { |
|
389 | 389 | echo $e->getMessage(); |
390 | 390 | die; |
391 | 391 | } |
@@ -397,24 +397,24 @@ discard block |
||
397 | 397 | * @return Array the spotter information |
398 | 398 | * |
399 | 399 | */ |
400 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
400 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
401 | 401 | { |
402 | 402 | global $globalDBdriver, $globalLiveInterval; |
403 | 403 | date_default_timezone_set('UTC'); |
404 | 404 | |
405 | 405 | $filter_query = ''; |
406 | 406 | if (isset($filter['source']) && !empty($filter['source'])) { |
407 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
407 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
408 | 408 | } |
409 | 409 | // Use spotter_output also ? |
410 | 410 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
411 | - $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 "; |
|
411 | + $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 "; |
|
412 | 412 | } |
413 | 413 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
414 | 414 | $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 "; |
415 | 415 | } |
416 | 416 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
417 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
417 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -433,14 +433,14 @@ discard block |
||
433 | 433 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
434 | 434 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
435 | 435 | */ |
436 | - $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 |
|
436 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
437 | 437 | FROM spotter_archive |
438 | 438 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
439 | 439 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
440 | 440 | '.$filter_query.' ORDER BY flightaware_id'; |
441 | 441 | } else { |
442 | 442 | //$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'; |
443 | - $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 |
|
443 | + $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 |
|
444 | 444 | FROM spotter_archive |
445 | 445 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
446 | 446 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | try { |
451 | 451 | $sth = $this->db->prepare($query); |
452 | 452 | $sth->execute(); |
453 | - } catch(PDOException $e) { |
|
453 | + } catch (PDOException $e) { |
|
454 | 454 | echo $e->getMessage(); |
455 | 455 | die; |
456 | 456 | } |
@@ -465,24 +465,24 @@ discard block |
||
465 | 465 | * @return Array the spotter information |
466 | 466 | * |
467 | 467 | */ |
468 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
468 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
469 | 469 | { |
470 | 470 | global $globalDBdriver, $globalLiveInterval; |
471 | 471 | date_default_timezone_set('UTC'); |
472 | 472 | |
473 | 473 | $filter_query = ''; |
474 | 474 | if (isset($filter['source']) && !empty($filter['source'])) { |
475 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
475 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
476 | 476 | } |
477 | 477 | // Should use spotter_output also ? |
478 | 478 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
479 | - $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 "; |
|
479 | + $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 "; |
|
480 | 480 | } |
481 | 481 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
482 | 482 | $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 "; |
483 | 483 | } |
484 | 484 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
485 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
485 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | FROM spotter_archive |
493 | 493 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
494 | 494 | */ |
495 | - $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 |
|
495 | + $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 |
|
496 | 496 | FROM spotter_archive_output |
497 | 497 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
498 | 498 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
508 | 508 | '.$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'; |
509 | 509 | */ |
510 | - $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 |
|
510 | + $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 |
|
511 | 511 | FROM spotter_archive_output |
512 | 512 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
513 | 513 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | try { |
520 | 520 | $sth = $this->db->prepare($query); |
521 | 521 | $sth->execute(); |
522 | - } catch(PDOException $e) { |
|
522 | + } catch (PDOException $e) { |
|
523 | 523 | echo $e->getMessage(); |
524 | 524 | die; |
525 | 525 | } |
@@ -534,23 +534,23 @@ discard block |
||
534 | 534 | * @return Array the spotter information |
535 | 535 | * |
536 | 536 | */ |
537 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
537 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
538 | 538 | { |
539 | 539 | global $globalDBdriver, $globalLiveInterval; |
540 | 540 | date_default_timezone_set('UTC'); |
541 | 541 | |
542 | 542 | $filter_query = ''; |
543 | 543 | if (isset($filter['source']) && !empty($filter['source'])) { |
544 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
544 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
545 | 545 | } |
546 | 546 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
547 | - $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 "; |
|
547 | + $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 "; |
|
548 | 548 | } |
549 | 549 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
550 | 550 | $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 "; |
551 | 551 | } |
552 | 552 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
553 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
553 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | try { |
566 | 566 | $sth = $this->db->prepare($query); |
567 | 567 | $sth->execute(); |
568 | - } catch(PDOException $e) { |
|
568 | + } catch (PDOException $e) { |
|
569 | 569 | echo $e->getMessage(); |
570 | 570 | die; |
571 | 571 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @return Array the spotter information |
586 | 586 | * |
587 | 587 | */ |
588 | - 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()) |
|
588 | + 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()) |
|
589 | 589 | { |
590 | 590 | global $globalTimezone, $globalDBdriver; |
591 | 591 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | $q_array = explode(" ", $q); |
609 | 609 | |
610 | - foreach ($q_array as $q_item){ |
|
610 | + foreach ($q_array as $q_item) { |
|
611 | 611 | $additional_query .= " AND ("; |
612 | 612 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
613 | 613 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | |
640 | 640 | if ($registration != "") |
641 | 641 | { |
642 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
642 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
643 | 643 | if (!is_string($registration)) |
644 | 644 | { |
645 | 645 | return false; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($aircraft_icao != "") |
652 | 652 | { |
653 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
653 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
654 | 654 | if (!is_string($aircraft_icao)) |
655 | 655 | { |
656 | 656 | return false; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($aircraft_manufacturer != "") |
663 | 663 | { |
664 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
664 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
665 | 665 | if (!is_string($aircraft_manufacturer)) |
666 | 666 | { |
667 | 667 | return false; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | |
683 | 683 | if ($airline_icao != "") |
684 | 684 | { |
685 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
685 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
686 | 686 | if (!is_string($airline_icao)) |
687 | 687 | { |
688 | 688 | return false; |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | |
694 | 694 | if ($airline_country != "") |
695 | 695 | { |
696 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
696 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
697 | 697 | if (!is_string($airline_country)) |
698 | 698 | { |
699 | 699 | return false; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | |
705 | 705 | if ($airline_type != "") |
706 | 706 | { |
707 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
707 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
708 | 708 | if (!is_string($airline_type)) |
709 | 709 | { |
710 | 710 | return false; |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | if ($airport != "") |
728 | 728 | { |
729 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
729 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
730 | 730 | if (!is_string($airport)) |
731 | 731 | { |
732 | 732 | return false; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | |
738 | 738 | if ($airport_country != "") |
739 | 739 | { |
740 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
740 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
741 | 741 | if (!is_string($airport_country)) |
742 | 742 | { |
743 | 743 | return false; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | |
749 | 749 | if ($callsign != "") |
750 | 750 | { |
751 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
751 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
752 | 752 | if (!is_string($callsign)) |
753 | 753 | { |
754 | 754 | return false; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $translate = $Translation->ident2icao($callsign); |
757 | 757 | if ($translate != $callsign) { |
758 | 758 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
759 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
759 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
760 | 760 | } else { |
761 | 761 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
762 | 762 | } |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | if ($owner != "") |
767 | 767 | { |
768 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
768 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
769 | 769 | if (!is_string($owner)) |
770 | 770 | { |
771 | 771 | return false; |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | if ($pilot_name != "") |
778 | 778 | { |
779 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
779 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
780 | 780 | if (!is_string($pilot_name)) |
781 | 781 | { |
782 | 782 | return false; |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | |
788 | 788 | if ($pilot_id != "") |
789 | 789 | { |
790 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
790 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
791 | 791 | if (!is_string($pilot_id)) |
792 | 792 | { |
793 | 793 | return false; |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | |
799 | 799 | if ($departure_airport_route != "") |
800 | 800 | { |
801 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
801 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
802 | 802 | if (!is_string($departure_airport_route)) |
803 | 803 | { |
804 | 804 | return false; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | |
810 | 810 | if ($arrival_airport_route != "") |
811 | 811 | { |
812 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
812 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
813 | 813 | if (!is_string($arrival_airport_route)) |
814 | 814 | { |
815 | 815 | return false; |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | { |
823 | 823 | $altitude_array = explode(",", $altitude); |
824 | 824 | |
825 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
826 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
825 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
826 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
827 | 827 | |
828 | 828 | |
829 | 829 | if ($altitude_array[1] != "") |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | if ($date_posted != "") |
841 | 841 | { |
842 | 842 | $date_array = explode(",", $date_posted); |
843 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
844 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
843 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
844 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
845 | 845 | if ($globalTimezone != '') { |
846 | 846 | date_default_timezone_set($globalTimezone); |
847 | 847 | $datetime = new DateTime(); |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | if ($limit != "") |
869 | 869 | { |
870 | 870 | $limit_array = explode(",", $limit); |
871 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
872 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
871 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
872 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
873 | 873 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
874 | 874 | { |
875 | 875 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | } |
878 | 878 | } |
879 | 879 | if ($origLat != "" && $origLon != "" && $dist != "") { |
880 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
881 | - $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 |
|
880 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
881 | + $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 |
|
882 | 882 | 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)) |
883 | 883 | 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"; |
884 | 884 | } else { |
@@ -894,12 +894,12 @@ discard block |
||
894 | 894 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
895 | 895 | } |
896 | 896 | |
897 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
897 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
898 | 898 | WHERE spotter_archive_output.ident <> '' |
899 | 899 | ".$additional_query." |
900 | 900 | ".$filter_query.$orderby_query; |
901 | 901 | } |
902 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
902 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
903 | 903 | return $spotter_array; |
904 | 904 | } |
905 | 905 | |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | try { |
915 | 915 | $sth = $this->db->prepare($query); |
916 | 916 | $sth->execute(); |
917 | - } catch(PDOException $e) { |
|
917 | + } catch (PDOException $e) { |
|
918 | 918 | return "error"; |
919 | 919 | } |
920 | 920 | } |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | { |
952 | 952 | $limit_array = explode(",", $limit); |
953 | 953 | |
954 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
955 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
954 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
955 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
956 | 956 | |
957 | 957 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
958 | 958 | { |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | $query_values = array(); |
994 | 994 | $limit_query = ''; |
995 | 995 | $additional_query = ''; |
996 | - $filter_query = $this->getFilter($filter,true,true); |
|
996 | + $filter_query = $this->getFilter($filter, true, true); |
|
997 | 997 | |
998 | 998 | if ($owner != "") |
999 | 999 | { |
@@ -1010,8 +1010,8 @@ discard block |
||
1010 | 1010 | { |
1011 | 1011 | $limit_array = explode(",", $limit); |
1012 | 1012 | |
1013 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1014 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1014 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1015 | 1015 | |
1016 | 1016 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1017 | 1017 | { |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $query_values = array(); |
1052 | 1052 | $limit_query = ''; |
1053 | 1053 | $additional_query = ''; |
1054 | - $filter_query = $this->getFilter($filter,true,true); |
|
1054 | + $filter_query = $this->getFilter($filter, true, true); |
|
1055 | 1055 | |
1056 | 1056 | if ($pilot != "") |
1057 | 1057 | { |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | { |
1064 | 1064 | $limit_array = explode(",", $limit); |
1065 | 1065 | |
1066 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1067 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1067 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1068 | 1068 | |
1069 | 1069 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1070 | 1070 | { |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | * @return Array the airline country list |
1095 | 1095 | * |
1096 | 1096 | */ |
1097 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1097 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1098 | 1098 | { |
1099 | 1099 | global $globalDBdriver; |
1100 | 1100 | /* |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | $flight_array = array(); |
1124 | 1124 | $temp_array = array(); |
1125 | 1125 | |
1126 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1126 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1127 | 1127 | { |
1128 | 1128 | $temp_array['flight_count'] = $row['nb']; |
1129 | 1129 | $temp_array['flight_country'] = $row['name']; |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | * @return Array the airline country list |
1141 | 1141 | * |
1142 | 1142 | */ |
1143 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1143 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1144 | 1144 | { |
1145 | 1145 | global $globalDBdriver; |
1146 | 1146 | /* |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | $flight_array = array(); |
1170 | 1170 | $temp_array = array(); |
1171 | 1171 | |
1172 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1172 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1173 | 1173 | { |
1174 | 1174 | $temp_array['airline_icao'] = $row['airline_icao']; |
1175 | 1175 | $temp_array['flight_count'] = $row['nb']; |
@@ -1187,14 +1187,14 @@ discard block |
||
1187 | 1187 | * @return Array the spotter information |
1188 | 1188 | * |
1189 | 1189 | */ |
1190 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1190 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1191 | 1191 | { |
1192 | 1192 | $Spotter = new Spotter($this->db); |
1193 | 1193 | date_default_timezone_set('UTC'); |
1194 | 1194 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1195 | - $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'; |
|
1196 | - $date = date('c',$date); |
|
1197 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1195 | + $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'; |
|
1196 | + $date = date('c', $date); |
|
1197 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1198 | 1198 | return $spotter_array; |
1199 | 1199 | } |
1200 | 1200 | |
@@ -1204,14 +1204,14 @@ discard block |
||
1204 | 1204 | * @return Array the spotter information |
1205 | 1205 | * |
1206 | 1206 | */ |
1207 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1207 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1208 | 1208 | { |
1209 | 1209 | $Spotter = new Spotter($this->db); |
1210 | 1210 | date_default_timezone_set('UTC'); |
1211 | 1211 | $ident = filter_var($ident, 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.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'; |
|
1213 | - $date = date('c',$date); |
|
1214 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':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.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'; |
|
1213 | + $date = date('c', $date); |
|
1214 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1215 | 1215 | return $spotter_array; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | * @return Array the spotter information |
1222 | 1222 | * |
1223 | 1223 | */ |
1224 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1224 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1225 | 1225 | { |
1226 | 1226 | global $global_query; |
1227 | 1227 | $Spotter = new Spotter($this->db); |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $query_values = array(); |
1230 | 1230 | $limit_query = ''; |
1231 | 1231 | $additional_query = ''; |
1232 | - $filter_query = $this->getFilter($filters,true,true); |
|
1232 | + $filter_query = $this->getFilter($filters, true, true); |
|
1233 | 1233 | |
1234 | 1234 | if ($airport != "") |
1235 | 1235 | { |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | { |
1247 | 1247 | $limit_array = explode(",", $limit); |
1248 | 1248 | |
1249 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1250 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1250 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1251 | 1251 | |
1252 | 1252 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1253 | 1253 | { |
@@ -17,62 +17,62 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
38 | 38 | if ($flt['airlines'][0] != '') { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $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 | + $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"; |
|
41 | 41 | } else { |
42 | - $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 | + $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"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $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 | + $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"; |
|
49 | 49 | } else { |
50 | - $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 | + $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"; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
54 | 54 | if (isset($flt['source'])) { |
55 | - $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 | + $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"; |
|
56 | 56 | } else { |
57 | - $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 | + $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"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
61 | 61 | if (isset($flt['source'])) { |
62 | - $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 | + $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"; |
|
63 | 63 | } else { |
64 | - $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 | + $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"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | 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']))) { |
68 | 68 | if (isset($flt['source'])) { |
69 | - $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 | + $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"; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
74 | 74 | if ($filter['airlines'][0] != '') { |
75 | - $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 | + $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"; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | $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 "; |
83 | 83 | } |
84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
85 | - $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 | + $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"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
88 | 88 | if (count($filter['source']) == 1) { |
89 | 89 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
90 | 90 | } else { |
91 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
91 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
119 | 119 | } |
120 | 120 | } |
121 | - $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"; |
|
121 | + $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"; |
|
122 | 122 | } |
123 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
124 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
124 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
125 | 125 | } |
126 | 126 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
127 | 127 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
128 | 128 | if ($filter_query_where != '') { |
129 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
129 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
130 | 130 | } |
131 | 131 | $filter_query = $filter_query_join.$filter_query_where; |
132 | 132 | return $filter_query; |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | if ($limit != '') |
150 | 150 | { |
151 | 151 | $limit_array = explode(',', $limit); |
152 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
153 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
152 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
153 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
154 | 154 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
155 | 155 | { |
156 | 156 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } else { |
175 | 175 | $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; |
176 | 176 | } |
177 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
177 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
178 | 178 | |
179 | 179 | return $spotter_array; |
180 | 180 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
191 | 191 | date_default_timezone_set('UTC'); |
192 | - $filter_query = $this->getFilter($filter,true,true); |
|
192 | + $filter_query = $this->getFilter($filter, true, true); |
|
193 | 193 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
194 | 194 | if ($globalDBdriver == 'mysql') { |
195 | 195 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $this->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | echo $e->getMessage(); |
217 | 217 | die; |
218 | 218 | } |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | * @return Array the spotter information |
227 | 227 | * |
228 | 228 | */ |
229 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
229 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
230 | 230 | { |
231 | 231 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
232 | 232 | date_default_timezone_set('UTC'); |
233 | 233 | $usecoord = false; |
234 | 234 | if (is_array($coord) && !empty($coord)) { |
235 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
236 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
237 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
238 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
235 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
236 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
237 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
238 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
239 | 239 | $usecoord = true; |
240 | 240 | } |
241 | - $filter_query = $this->getFilter($filter,true,true); |
|
241 | + $filter_query = $this->getFilter($filter, true, true); |
|
242 | 242 | |
243 | 243 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
244 | 244 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute(); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | echo $e->getMessage(); |
304 | 304 | die; |
305 | 305 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | public function getLiveSpotterCount($filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
319 | - $filter_query = $this->getFilter($filter,true,true); |
|
319 | + $filter_query = $this->getFilter($filter, true, true); |
|
320 | 320 | |
321 | 321 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | try { |
330 | 330 | $sth = $this->db->prepare($query); |
331 | 331 | $sth->execute(); |
332 | - } catch(PDOException $e) { |
|
332 | + } catch (PDOException $e) { |
|
333 | 333 | echo $e->getMessage(); |
334 | 334 | die; |
335 | 335 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | $filter_query = $this->getFilter($filter); |
353 | 353 | |
354 | 354 | if (is_array($coord)) { |
355 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
356 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
357 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
358 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
355 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
356 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
357 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
358 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
359 | 359 | } else return array(); |
360 | 360 | if ($globalDBdriver == 'mysql') { |
361 | 361 | $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; |
@@ -378,23 +378,23 @@ discard block |
||
378 | 378 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
379 | 379 | $Spotter = new Spotter($this->db); |
380 | 380 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
381 | - $filter_query = $this->getFilter($filter,true,true); |
|
381 | + $filter_query = $this->getFilter($filter, true, true); |
|
382 | 382 | |
383 | 383 | if (is_array($coord)) { |
384 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
385 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
386 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
387 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
384 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
385 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
386 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
387 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
388 | 388 | } else return array(); |
389 | 389 | if ($globalDBdriver == 'mysql') { |
390 | 390 | if (isset($globalArchive) && $globalArchive === TRUE) { |
391 | - $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 |
|
391 | + $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 |
|
392 | 392 | FROM spotter_live |
393 | 393 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
394 | 394 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
395 | 395 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
396 | 396 | } else { |
397 | - $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 |
|
397 | + $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 |
|
398 | 398 | FROM spotter_live |
399 | 399 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
400 | 400 | FROM spotter_live l |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | if (isset($globalArchive) && $globalArchive === TRUE) { |
409 | - $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 |
|
409 | + $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 |
|
410 | 410 | FROM spotter_live |
411 | 411 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
412 | 412 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
413 | 413 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
414 | 414 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
415 | 415 | } else { |
416 | - $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 |
|
416 | + $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 |
|
417 | 417 | FROM spotter_live |
418 | 418 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
419 | 419 | FROM spotter_live l |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | try { |
429 | 429 | $sth = $this->db->prepare($query); |
430 | 430 | $sth->execute(); |
431 | - } catch(PDOException $e) { |
|
431 | + } catch (PDOException $e) { |
|
432 | 432 | echo $e->getMessage(); |
433 | 433 | die; |
434 | 434 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | if ($interval == '1m') |
478 | 478 | { |
479 | 479 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
480 | - } else if ($interval == '15m'){ |
|
480 | + } else if ($interval == '15m') { |
|
481 | 481 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
482 | 482 | } |
483 | 483 | } |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
486 | 486 | } |
487 | 487 | |
488 | - $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 |
|
488 | + $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 |
|
489 | 489 | WHERE spotter_live.latitude <> '' |
490 | 490 | AND spotter_live.longitude <> '' |
491 | 491 | ".$additional_query." |
492 | 492 | HAVING distance < :radius |
493 | 493 | ORDER BY distance"; |
494 | 494 | |
495 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
495 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
496 | 496 | |
497 | 497 | return $spotter_array; |
498 | 498 | } |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | date_default_timezone_set('UTC'); |
511 | 511 | |
512 | 512 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
513 | - $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'; |
|
513 | + $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'; |
|
514 | 514 | |
515 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
515 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
516 | 516 | |
517 | 517 | return $spotter_array; |
518 | 518 | } |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | * @return Array the spotter information |
524 | 524 | * |
525 | 525 | */ |
526 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
526 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
527 | 527 | { |
528 | 528 | $Spotter = new Spotter($this->db); |
529 | 529 | date_default_timezone_set('UTC'); |
530 | 530 | |
531 | 531 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
532 | - $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'; |
|
532 | + $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'; |
|
533 | 533 | |
534 | - $date = date('c',$date); |
|
535 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
534 | + $date = date('c', $date); |
|
535 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
536 | 536 | |
537 | 537 | return $spotter_array; |
538 | 538 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | $Spotter = new Spotter($this->db); |
549 | 549 | date_default_timezone_set('UTC'); |
550 | 550 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
551 | - $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'; |
|
552 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
551 | + $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'; |
|
552 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
553 | 553 | return $spotter_array; |
554 | 554 | } |
555 | 555 | |
@@ -559,15 +559,15 @@ discard block |
||
559 | 559 | * @return Array the spotter information |
560 | 560 | * |
561 | 561 | */ |
562 | - public function getDateLiveSpotterDataById($id,$date) |
|
562 | + public function getDateLiveSpotterDataById($id, $date) |
|
563 | 563 | { |
564 | 564 | $Spotter = new Spotter($this->db); |
565 | 565 | date_default_timezone_set('UTC'); |
566 | 566 | |
567 | 567 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
568 | - $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'; |
|
569 | - $date = date('c',$date); |
|
570 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
568 | + $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'; |
|
569 | + $date = date('c', $date); |
|
570 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
571 | 571 | return $spotter_array; |
572 | 572 | } |
573 | 573 | |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | date_default_timezone_set('UTC'); |
584 | 584 | |
585 | 585 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
586 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
586 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
587 | 587 | |
588 | 588 | try { |
589 | 589 | |
590 | 590 | $sth = $this->db->prepare($query); |
591 | 591 | $sth->execute(array(':ident' => $ident)); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | echo $e->getMessage(); |
594 | 594 | die; |
595 | 595 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return Array the spotter information |
605 | 605 | * |
606 | 606 | */ |
607 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
607 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
608 | 608 | { |
609 | 609 | global $globalDBdriver, $globalLiveInterval; |
610 | 610 | date_default_timezone_set('UTC'); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | try { |
624 | 624 | $sth = $this->db->prepare($query); |
625 | 625 | $sth->execute(array(':id' => $id)); |
626 | - } catch(PDOException $e) { |
|
626 | + } catch (PDOException $e) { |
|
627 | 627 | echo $e->getMessage(); |
628 | 628 | die; |
629 | 629 | } |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | { |
642 | 642 | date_default_timezone_set('UTC'); |
643 | 643 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
644 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
644 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
645 | 645 | try { |
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(array(':ident' => $ident)); |
649 | - } catch(PDOException $e) { |
|
649 | + } catch (PDOException $e) { |
|
650 | 650 | echo $e->getMessage(); |
651 | 651 | die; |
652 | 652 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | |
677 | 677 | $sth = $this->db->prepare($query); |
678 | 678 | $sth->execute(); |
679 | - } catch(PDOException $e) { |
|
679 | + } catch (PDOException $e) { |
|
680 | 680 | return "error"; |
681 | 681 | } |
682 | 682 | |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | |
700 | 700 | $sth = $this->db->prepare($query); |
701 | 701 | $sth->execute(); |
702 | - } catch(PDOException $e) { |
|
702 | + } catch (PDOException $e) { |
|
703 | 703 | return "error"; |
704 | 704 | } |
705 | 705 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
706 | 706 | $i = 0; |
707 | - $j =0; |
|
707 | + $j = 0; |
|
708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
709 | - foreach($all as $row) |
|
709 | + foreach ($all as $row) |
|
710 | 710 | { |
711 | 711 | $i++; |
712 | 712 | $j++; |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | if ($globalDebug) echo "."; |
715 | 715 | try { |
716 | 716 | |
717 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
717 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
718 | 718 | $sth->execute(); |
719 | - } catch(PDOException $e) { |
|
719 | + } catch (PDOException $e) { |
|
720 | 720 | return "error"; |
721 | 721 | } |
722 | 722 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | if ($i > 0) { |
728 | 728 | try { |
729 | 729 | |
730 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
730 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
731 | 731 | $sth->execute(); |
732 | - } catch(PDOException $e) { |
|
732 | + } catch (PDOException $e) { |
|
733 | 733 | return "error"; |
734 | 734 | } |
735 | 735 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(); |
745 | - } catch(PDOException $e) { |
|
745 | + } catch (PDOException $e) { |
|
746 | 746 | return "error"; |
747 | 747 | } |
748 | 748 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -790,13 +790,13 @@ discard block |
||
790 | 790 | public function deleteLiveSpotterDataByIdent($ident) |
791 | 791 | { |
792 | 792 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
793 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
793 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
794 | 794 | |
795 | 795 | try { |
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':ident' => $ident)); |
799 | - } catch(PDOException $e) { |
|
799 | + } catch (PDOException $e) { |
|
800 | 800 | return "error"; |
801 | 801 | } |
802 | 802 | |
@@ -812,13 +812,13 @@ discard block |
||
812 | 812 | public function deleteLiveSpotterDataById($id) |
813 | 813 | { |
814 | 814 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
815 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
815 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
816 | 816 | |
817 | 817 | try { |
818 | 818 | |
819 | 819 | $sth = $this->db->prepare($query); |
820 | 820 | $sth->execute(array(':id' => $id)); |
821 | - } catch(PDOException $e) { |
|
821 | + } catch (PDOException $e) { |
|
822 | 822 | return "error"; |
823 | 823 | } |
824 | 824 | |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
838 | 838 | if ($globalDBdriver == 'mysql') { |
839 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
839 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
840 | 840 | WHERE spotter_live.ident = :ident |
841 | 841 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
842 | 842 | AND spotter_live.date < UTC_TIMESTAMP()'; |
843 | 843 | $query_data = array(':ident' => $ident); |
844 | 844 | } else { |
845 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
845 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
846 | 846 | WHERE spotter_live.ident = :ident |
847 | 847 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
854 | + $ident_result = ''; |
|
855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | { |
870 | 870 | global $globalDBdriver, $globalTimezone; |
871 | 871 | if ($globalDBdriver == 'mysql') { |
872 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
872 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
873 | 873 | WHERE spotter_live.ident = :ident |
874 | 874 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
875 | 875 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
876 | 876 | $query_data = array(':ident' => $ident); |
877 | 877 | } else { |
878 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
878 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
879 | 879 | WHERE spotter_live.ident = :ident |
880 | 880 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
881 | 881 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_data); |
887 | - $ident_result=''; |
|
888 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
887 | + $ident_result = ''; |
|
888 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
889 | 889 | { |
890 | 890 | $ident_result = $row['flightaware_id']; |
891 | 891 | } |
@@ -902,13 +902,13 @@ discard block |
||
902 | 902 | { |
903 | 903 | global $globalDBdriver, $globalTimezone; |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
905 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
906 | 906 | WHERE spotter_live.flightaware_id = :id |
907 | 907 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
908 | 908 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
909 | 909 | $query_data = array(':id' => $id); |
910 | 910 | } else { |
911 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
911 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
912 | 912 | WHERE spotter_live.flightaware_id = :id |
913 | 913 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
914 | 914 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | |
918 | 918 | $sth = $this->db->prepare($query); |
919 | 919 | $sth->execute($query_data); |
920 | - $ident_result=''; |
|
921 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
920 | + $ident_result = ''; |
|
921 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
922 | 922 | { |
923 | 923 | $ident_result = $row['flightaware_id']; |
924 | 924 | } |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | { |
936 | 936 | global $globalDBdriver, $globalTimezone; |
937 | 937 | if ($globalDBdriver == 'mysql') { |
938 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
938 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
939 | 939 | WHERE spotter_live.ModeS = :modes |
940 | 940 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
941 | 941 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
942 | 942 | $query_data = array(':modes' => $modes); |
943 | 943 | } else { |
944 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
944 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
945 | 945 | WHERE spotter_live.ModeS = :modes |
946 | 946 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
947 | 947 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | |
951 | 951 | $sth = $this->db->prepare($query); |
952 | 952 | $sth->execute($query_data); |
953 | - $ident_result=''; |
|
954 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
953 | + $ident_result = ''; |
|
954 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
955 | 955 | { |
956 | 956 | //$ident_result = $row['spotter_live_id']; |
957 | 957 | $ident_result = $row['flightaware_id']; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | * @return String success or false |
971 | 971 | * |
972 | 972 | */ |
973 | - 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 = '') |
|
973 | + 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 = '') |
|
974 | 974 | { |
975 | 975 | global $globalURL, $globalArchive, $globalDebug; |
976 | 976 | $Common = new Common(); |
@@ -1070,27 +1070,27 @@ discard block |
||
1070 | 1070 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1071 | 1071 | |
1072 | 1072 | |
1073 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1074 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1075 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1076 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1077 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1078 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1080 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1081 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1082 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1083 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1085 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1086 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1087 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1088 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1089 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1090 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1091 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1092 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1093 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1073 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1074 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1075 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1076 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1077 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1078 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1080 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1081 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1082 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1083 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1085 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1086 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1087 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1088 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1089 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1090 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1091 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1092 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1093 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1094 | 1094 | |
1095 | 1095 | $airline_name = ''; |
1096 | 1096 | $airline_icao = ''; |
@@ -1112,10 +1112,10 @@ discard block |
||
1112 | 1112 | $arrival_airport_country = ''; |
1113 | 1113 | |
1114 | 1114 | |
1115 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1116 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1117 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1118 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1115 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1116 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1117 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1118 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1119 | 1119 | |
1120 | 1120 | $query = ''; |
1121 | 1121 | if ($globalArchive) { |
@@ -1126,19 +1126,19 @@ discard block |
||
1126 | 1126 | $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, real_altitude) |
1127 | 1127 | 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, :real_altitude)'; |
1128 | 1128 | |
1129 | - $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,':real_altitude' => $altitude_real); |
|
1129 | + $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, ':real_altitude' => $altitude_real); |
|
1130 | 1130 | try { |
1131 | 1131 | |
1132 | 1132 | $sth = $this->db->prepare($query); |
1133 | 1133 | $sth->execute($query_values); |
1134 | 1134 | $sth->closeCursor(); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1139 | 1139 | if ($globalDebug) echo '(Add to SBS archive : '; |
1140 | 1140 | $SpotterArchive = new SpotterArchive($this->db); |
1141 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1141 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1142 | 1142 | if ($globalDebug) echo $result.')'; |
1143 | 1143 | } elseif ($globalDebug && $putinarchive !== true) { |
1144 | 1144 | echo '(Not adding to archive)'; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | public function getOrderBy() |
1153 | 1153 | { |
1154 | - $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")); |
|
1154 | + $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")); |
|
1155 | 1155 | return $orderby; |
1156 | 1156 | } |
1157 | 1157 |
@@ -12,52 +12,52 @@ discard block |
||
12 | 12 | if (!isset($globalDemo)) { |
13 | 13 | if (isset($_GET['coord'])) |
14 | 14 | { |
15 | - $coords = explode(',',$_GET['coord']); |
|
15 | + $coords = explode(',', $_GET['coord']); |
|
16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
17 | 17 | || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
19 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords)); |
|
19 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs', $coords)); |
|
20 | 20 | } |
21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
22 | 22 | || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
23 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords)); |
|
23 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx', $coords)); |
|
24 | 24 | } |
25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
26 | 26 | || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
27 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords)); |
|
27 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning', $coords)); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
31 | 31 | || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
32 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true)); |
|
32 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', $coords, true)); |
|
33 | 33 | } |
34 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
|
34 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('')); |
|
35 | 35 | } else { |
36 | 36 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
37 | 37 | || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
38 | 38 | //$spotter_array = $Source->getAllLocationInfo(); |
39 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
|
39 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs')); |
|
40 | 40 | } |
41 | 41 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
42 | 42 | || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
43 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
|
43 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx')); |
|
44 | 44 | } |
45 | 45 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
46 | 46 | || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
47 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
|
47 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning')); |
|
48 | 48 | } |
49 | 49 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
50 | 50 | || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
51 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true)); |
|
51 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', array(), true)); |
|
52 | 52 | } |
53 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
|
53 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('')); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | $output = '{"type": "FeatureCollection","features": ['; |
58 | 58 | if (!empty($spotter_array) && count($spotter_array) > 0) |
59 | 59 | { |
60 | - foreach($spotter_array as $spotter_item) |
|
60 | + foreach ($spotter_array as $spotter_item) |
|
61 | 61 | { |
62 | 62 | date_default_timezone_set('UTC'); |
63 | 63 | $output .= '{"type": "Feature",'; |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",'; |
77 | 77 | $output .= '"type": "'.$spotter_item['type'].'",'; |
78 | 78 | if ($spotter_item['type'] == 'wx') { |
79 | - $weather = json_decode($spotter_item['description'],true); |
|
80 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
79 | + $weather = json_decode($spotter_item['description'], true); |
|
80 | + if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",'; |
|
81 | 81 | } |
82 | 82 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
83 | 83 | $output .= '},'; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $output .= '}'; |
88 | 88 | $output .= '},'; |
89 | 89 | } |
90 | - $output = substr($output, 0, -1); |
|
90 | + $output = substr($output, 0, -1); |
|
91 | 91 | } |
92 | 92 | $output .= ']}'; |
93 | 93 | print $output; |