These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | require_once('require/class.Connection.php'); |
||
3 | require_once('require/class.Common.php'); |
||
4 | $tracker = false; |
||
5 | $marine = false; |
||
6 | if (isset($_GET['tracker'])) { |
||
7 | $tracker = true; |
||
8 | } |
||
9 | if (isset($_GET['marine'])) { |
||
10 | $marine = true; |
||
11 | } |
||
12 | if ($tracker) { |
||
13 | require_once('require/class.Tracker.php'); |
||
14 | require_once('require/class.TrackerLive.php'); |
||
15 | //require_once('require/class.TrackerArchive.php'); |
||
16 | } elseif ($marine) { |
||
17 | require_once('require/class.Marine.php'); |
||
18 | require_once('require/class.MarineLive.php'); |
||
19 | //require_once('require/class.MarineArchive.php'); |
||
20 | } else { |
||
21 | require_once('require/class.Spotter.php'); |
||
22 | require_once('require/class.SpotterLive.php'); |
||
23 | require_once('require/class.SpotterArchive.php'); |
||
24 | } |
||
25 | |||
26 | $begintime = microtime(true); |
||
27 | if ($tracker) { |
||
28 | $TrackerLive = new TrackerLive(); |
||
29 | $Tracker = new Tracker(); |
||
30 | //$TrackerArchive = new TrackerArchive(); |
||
31 | } elseif ($marine) { |
||
32 | $MarineLive = new MarineLive(); |
||
33 | $Marine = new Marine(); |
||
34 | //$MarineArchive = new MarineArchive(); |
||
35 | } else { |
||
36 | $SpotterLive = new SpotterLive(); |
||
37 | $Spotter = new Spotter(); |
||
38 | $SpotterArchive = new SpotterArchive(); |
||
39 | } |
||
40 | $Common = new Common(); |
||
41 | |||
42 | if (isset($_GET['download'])) { |
||
43 | if ($_GET['download'] == "true") |
||
44 | { |
||
45 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
||
46 | } |
||
47 | } |
||
48 | header('Content-Type: text/javascript'); |
||
49 | |||
50 | if (!isset($globalJsonCompress)) $compress = true; |
||
51 | else $compress = $globalJsonCompress; |
||
52 | |||
53 | $from_archive = false; |
||
54 | $min = true; |
||
55 | $allhistory = false; |
||
56 | $filter['source'] = array(); |
||
57 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
||
58 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
||
59 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
||
60 | if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
||
61 | if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
||
62 | if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
||
63 | if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
||
64 | if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
||
65 | if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
||
66 | if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
||
67 | |||
68 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
||
69 | $min = true; |
||
70 | } else $min = false; |
||
71 | |||
72 | if (isset($_GET['ident'])) { |
||
73 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
||
74 | if ($tracker) { |
||
75 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
||
76 | } elseif ($marine) { |
||
77 | $spotter_array = $MarineLive->getLastLiveMarineDataByIdent($ident); |
||
78 | } else { |
||
79 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
||
80 | if (empty($spotter_array)) { |
||
81 | $from_archive = true; |
||
82 | $spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident); |
||
83 | } |
||
84 | } |
||
85 | $allhistory = true; |
||
86 | } elseif (isset($_GET['flightaware_id'])) { |
||
87 | $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
||
88 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
||
89 | if (empty($spotter_array)) { |
||
90 | $from_archive = true; |
||
91 | $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
||
92 | } |
||
93 | $allhistory = true; |
||
94 | } elseif (isset($_GET['famtrack_id'])) { |
||
95 | $famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING); |
||
96 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
||
97 | $allhistory = true; |
||
98 | } elseif (isset($_GET['fammarine_id'])) { |
||
99 | $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
||
100 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
||
101 | $allhistory = true; |
||
102 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
||
103 | //if (isset($_GET['coord'])) { |
||
104 | $coord = explode(',',$_GET['coord']); |
||
105 | if ($tracker) { |
||
106 | $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
||
107 | } elseif ($marine) { |
||
108 | $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
||
109 | } else { |
||
110 | $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
||
111 | } |
||
112 | |||
113 | #} elseif (isset($globalMapPopup) && !$globalMapPopup) { |
||
114 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
||
115 | $from_archive = true; |
||
116 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
||
117 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
||
118 | $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
||
119 | $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
||
120 | $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
||
121 | $begindate = date('Y-m-d H:i:s',$begindate); |
||
122 | $enddate = date('Y-m-d H:i:s',$enddate); |
||
123 | $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
||
124 | } elseif ($min) { |
||
125 | if ($tracker) { |
||
126 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
||
127 | } elseif ($marine) { |
||
128 | $spotter_array = $MarineLive->getMinLiveMarineData($filter); |
||
129 | } else { |
||
130 | $spotter_array = $SpotterLive->getMinLiveSpotterData($filter); |
||
131 | } |
||
132 | # $min = true; |
||
133 | } else { |
||
134 | if ($tracker) { |
||
135 | $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
||
136 | } elseif ($marine) { |
||
137 | $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
||
138 | } else { |
||
139 | $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
||
140 | } |
||
141 | } |
||
142 | |||
143 | if (!empty($spotter_array)) { |
||
144 | /* |
||
145 | if (isset($_GET['archive'])) { |
||
146 | $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
||
147 | } else { |
||
148 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
||
149 | } |
||
150 | */ |
||
151 | $flightcnt = count($spotter_array); |
||
152 | if ($flightcnt == '') $flightcnt = 0; |
||
153 | } else $flightcnt = 0; |
||
154 | |||
155 | $sqltime = round(microtime(true)-$begintime,2); |
||
156 | |||
157 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
||
158 | else $usenextlatlon = true; |
||
159 | $j = 0; |
||
160 | $prev_flightaware_id = ''; |
||
161 | $aircrafts_shadow = array(); |
||
162 | $output = '{'; |
||
163 | $output .= '"type": "FeatureCollection",'; |
||
164 | if ($min) $output .= '"minimal": "true",'; |
||
165 | else $output .= '"minimal": "false",'; |
||
166 | $output .= '"fc": "'.$flightcnt.'",'; |
||
167 | $output .= '"sqt": "'.$sqltime.'",'; |
||
168 | |||
169 | if (!empty($spotter_array) && is_array($spotter_array)) |
||
170 | { |
||
171 | $output .= '"features": ['; |
||
172 | foreach($spotter_array as $spotter_item) |
||
173 | { |
||
174 | $j++; |
||
175 | date_default_timezone_set('UTC'); |
||
176 | |||
177 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
||
178 | { |
||
179 | $image = $spotter_item['image_thumbnail']; |
||
180 | } else { |
||
181 | $image = "images/placeholder_thumb.png"; |
||
182 | } |
||
183 | |||
184 | /* |
||
185 | if ($prev_flightaware_id != $spotter_item['flightaware_id']) { |
||
186 | if ($prev_flightaware_id != '') { |
||
187 | $output .= ']'; |
||
188 | $output .= '}'; |
||
189 | $output .= '},'; |
||
190 | } |
||
191 | $prev_flightaware_id = $spotter_item['flightaware_id']; |
||
192 | */ |
||
193 | |||
194 | //location of aircraft |
||
195 | // print_r($spotter_item); |
||
196 | $output .= '{'; |
||
197 | $output .= '"type": "Feature",'; |
||
198 | //$output .= '"fc": "'.$flightcnt.'",'; |
||
199 | //$output .= '"sqt": "'.$sqltime.'",'; |
||
200 | if (isset($spotter_item['flightaware_id'])) { |
||
201 | $output .= '"id": "'.$spotter_item['flightaware_id'].'",'; |
||
202 | } elseif (isset($spotter_item['famtrackid'])) { |
||
203 | $output .= '"id": "'.$spotter_item['famtrackid'].'",'; |
||
204 | } elseif (isset($spotter_item['fammarine_id'])) { |
||
205 | $output .= '"id": "'.$spotter_item['fammarine_id'].'",'; |
||
206 | } |
||
207 | $output .= '"properties": {'; |
||
208 | if (isset($spotter_item['flightaware_id'])) { |
||
209 | if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
||
210 | else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
||
211 | } elseif (isset($spotter_item['famtrackid'])) { |
||
212 | if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
||
213 | else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
||
214 | } elseif (isset($spotter_item['fammarine_id'])) { |
||
215 | if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
||
216 | else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
||
217 | } |
||
218 | $output .= '"fc": "'.$flightcnt.'",'; |
||
219 | $output .= '"sqt": "'.$sqltime.'",'; |
||
220 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
||
221 | |||
222 | /* |
||
223 | if ($min) $output .= '"minimal": "true",'; |
||
224 | else $output .= '"minimal": "false",'; |
||
225 | */ |
||
226 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
||
227 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
||
228 | if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
||
229 | else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
||
230 | } else { |
||
231 | if ($compress) $output .= '"c": "NA",'; |
||
232 | else $output .= '"callsign": "NA",'; |
||
233 | } |
||
234 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
||
235 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
||
236 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
||
237 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
||
238 | } elseif (isset($spotter_item['aircraft_type'])) { |
||
239 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
||
240 | } elseif (!$min) { |
||
241 | $output .= '"aircraft_name": "NA",'; |
||
242 | } |
||
243 | if (!$min && isset($spotter_item['aircraft_icao'])) { |
||
244 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
||
245 | } |
||
246 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
||
247 | if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
||
248 | else { |
||
249 | $aircraft_icao = $spotter_item['aircraft_icao']; |
||
250 | if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
||
251 | else { |
||
252 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
||
253 | if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
||
254 | elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
||
255 | else $spotter_item['aircraft_shadow'] = ''; |
||
256 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
||
257 | } |
||
258 | } |
||
259 | } |
||
260 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
||
261 | if ($tracker) { |
||
262 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
||
263 | if ($compress) $output .= '"as": "ambulance.png",'; |
||
264 | else $output .= '"aircraft_shadow": "ambulance.png",'; |
||
265 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
||
266 | if ($compress) $output .= '"as": "police.png",'; |
||
267 | else $output .= '"aircraft_shadow": "police.png",'; |
||
268 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
||
269 | if ($compress) $output .= '"as": "ship.png",'; |
||
270 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
271 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
||
272 | if ($compress) $output .= '"as": "ship.png",'; |
||
273 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
274 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
||
275 | if ($compress) $output .= '"as": "ship.png",'; |
||
276 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
277 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
||
278 | if ($compress) $output .= '"as": "truck.png",'; |
||
279 | else $output .= '"aircraft_shadow": "truck.png",'; |
||
280 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
||
281 | if ($compress) $output .= '"as": "truck.png",'; |
||
282 | else $output .= '"aircraft_shadow": "truck.png",'; |
||
283 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
||
284 | if ($compress) $output .= '"as": "aircraft.png",'; |
||
285 | else $output .= '"aircraft_shadow": "aircraft.png",'; |
||
286 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
||
287 | if ($compress) $output .= '"as": "aircraft.png",'; |
||
288 | else $output .= '"aircraft_shadow": "aircraft.png",'; |
||
289 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
||
290 | if ($compress) $output .= '"as": "helico.png",'; |
||
291 | else $output .= '"aircraft_shadow": "helico.png",'; |
||
292 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
||
293 | if ($compress) $output .= '"as": "rail.png",'; |
||
294 | else $output .= '"aircraft_shadow": "rail.png",'; |
||
295 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
||
296 | if ($compress) $output .= '"as": "firetruck.png",'; |
||
297 | else $output .= '"aircraft_shadow": "firetruck.png",'; |
||
298 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
||
299 | if ($compress) $output .= '"as": "bus.png",'; |
||
300 | else $output .= '"aircraft_shadow": "bus.png",'; |
||
301 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
||
302 | if ($compress) $output .= '"as": "phone.png",'; |
||
303 | else $output .= '"aircraft_shadow": "phone.png",'; |
||
304 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
||
305 | if ($compress) $output .= '"as": "jogger.png",'; |
||
306 | else $output .= '"aircraft_shadow": "jogger.png",'; |
||
307 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
||
308 | if ($compress) $output .= '"as": "bike.png",'; |
||
309 | else $output .= '"aircraft_shadow": "bike.png",'; |
||
310 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
||
311 | if ($compress) $output .= '"as": "motorcycle.png",'; |
||
312 | else $output .= '"aircraft_shadow": "motorcycle.png",'; |
||
313 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
||
314 | if ($compress) $output .= '"as": "balloon.png",'; |
||
315 | else $output .= '"aircraft_shadow": "balloon.png",'; |
||
316 | } else { |
||
317 | if ($compress) $output .= '"as": "car.png",'; |
||
318 | else $output .= '"aircraft_shadow": "car.png",'; |
||
319 | } |
||
320 | } elseif ($marine) { |
||
321 | if ($compress) $output .= '"as": "ship.png",'; |
||
322 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
323 | } else { |
||
324 | if ($compress) $output .= '"as": "default.png",'; |
||
325 | else $output .= '"aircraft_shadow": "default.png",'; |
||
326 | } |
||
327 | } else { |
||
328 | if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
||
329 | else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
||
330 | } |
||
331 | if (isset($spotter_item['airline_name'])) { |
||
332 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
||
333 | } elseif (!$min) { |
||
334 | $output .= '"airline_name": "NA",'; |
||
335 | } |
||
336 | if (isset($spotter_item['departure_airport'])) { |
||
337 | if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
||
338 | else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
||
339 | } |
||
340 | if (isset($spotter_item['departure_airport_city'])) { |
||
341 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
||
342 | } |
||
343 | if (isset($spotter_item['departure_airport_time'])) { |
||
344 | $output .= '"departure_airport_time": "'.$spotter_item['departure_airport_time'].'",'; |
||
345 | } |
||
346 | if (isset($spotter_item['arrival_airport_time'])) { |
||
347 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
||
348 | } |
||
349 | if (isset($spotter_item['arrival_airport'])) { |
||
350 | if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
||
351 | else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
||
352 | } |
||
353 | if (isset($spotter_item['arrival_airport_city'])) { |
||
354 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
||
355 | } |
||
356 | |||
357 | if (isset($spotter_item['date_iso_8601'])) { |
||
358 | $output .= '"date_update": "'.date("M j, Y, g:i a T", strtotime($spotter_item['date_iso_8601'])).'",'; |
||
359 | } |
||
360 | if (isset($spotter_item['date'])) { |
||
361 | $output .= '"lu": "'.strtotime($spotter_item['date']).'",'; |
||
362 | } |
||
363 | if (!$min) { |
||
364 | $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
||
365 | $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
||
366 | $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
||
367 | } |
||
368 | |||
369 | if (isset($spotter_item['altitude'])) { |
||
370 | if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
||
371 | else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
||
372 | } |
||
373 | if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
||
374 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
||
375 | |||
376 | if (isset($archivespeed)) { |
||
377 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
||
378 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
379 | } elseif ($usenextlatlon) { |
||
380 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
||
381 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
382 | } |
||
383 | |||
384 | if (!$min) $output .= '"image": "'.$image.'",'; |
||
385 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
||
386 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
||
387 | } |
||
388 | if (isset($spotter_item['image_source_website'])) { |
||
389 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
||
390 | } |
||
391 | if (isset($spotter_item['squawk'])) { |
||
392 | if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
||
393 | else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
||
394 | } |
||
395 | if (isset($spotter_item['squawk_usage'])) { |
||
396 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
||
397 | } |
||
398 | if (isset($spotter_item['pilot_id'])) { |
||
399 | $output .= '"pilot_id": "'.$spotter_item['pilot_id'].'",'; |
||
400 | } |
||
401 | if (isset($spotter_item['pilot_name'])) { |
||
402 | $output .= '"pilot_name": "'.$spotter_item['pilot_name'].'",'; |
||
403 | } |
||
404 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
||
405 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
||
406 | } |
||
407 | if (isset($spotter_item['acars'])) { |
||
408 | $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
||
409 | } |
||
410 | // type when not aircraft ? |
||
411 | if (isset($spotter_item['type'])) { |
||
412 | if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
||
413 | else $output .= '"type": "'.$spotter_item['type'].'"'; |
||
414 | } elseif ($marine) { |
||
415 | if ($compress) $output .= '"t": "ship"'; |
||
416 | else $output .= '"type": "ship"'; |
||
417 | } else { |
||
418 | if ($compress) $output .= '"t": "aircraft"'; |
||
419 | else $output .= '"type": "aircraft"'; |
||
420 | } |
||
421 | $output .= '},'; |
||
422 | $output .= '"geometry": {'; |
||
423 | $output .= '"type": "Point",'; |
||
424 | $output .= '"coordinates": ['; |
||
425 | $output .= $spotter_item['longitude'].', '; |
||
426 | $output .= $spotter_item['latitude']; |
||
427 | /* |
||
428 | .', '; |
||
429 | $output .= $spotter_item['altitude']*30.48; |
||
430 | $output .= ', '.strtotime($spotter_item['date']); |
||
431 | */ |
||
432 | $output .= ']'; |
||
433 | $output .= '}'; |
||
434 | $output .= '},'; |
||
435 | |||
436 | /* } else { |
||
437 | $output .= ', '; |
||
438 | $output .= $spotter_item['longitude'].', '; |
||
439 | $output .= $spotter_item['latitude'].', '; |
||
440 | $output .= $spotter_item['altitude']*30.48; |
||
441 | $output .= ', '.strtotime($spotter_item['date']); |
||
442 | |||
443 | } |
||
444 | */ |
||
445 | |||
446 | /* |
||
447 | //previous location history of aircraft |
||
448 | $output .= '{'; |
||
449 | $output .= '"type": "Feature",'; |
||
450 | $output .= '"properties": {'; |
||
451 | $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
||
452 | $output .= '"type": "history"'; |
||
453 | $output .= '},'; |
||
454 | $output .= '"geometry": {'; |
||
455 | $output .= '"type": "LineString",'; |
||
456 | $output .= '"coordinates": ['; |
||
457 | //$spotter_history_array = SpotterLive::getAllLiveSpotterDataByIdent($spotter_item['ident']); |
||
458 | if ($from_archive) { |
||
459 | $spotter_history_array = SpotterArchive::getAllArchiveSpotterDataById($spotter_item['flightaware_id']); |
||
460 | } else { |
||
461 | $spotter_history_array = SpotterLive::getAllLiveSpotterDataById($spotter_item['flightaware_id']); |
||
462 | } |
||
463 | $d = false; |
||
464 | $neg = false; |
||
465 | $history_output = ''; |
||
466 | foreach ($spotter_history_array as $key => $spotter_history) |
||
467 | { |
||
468 | if (abs($spotter_history['longitude']-$spotter_item['longitude']) > 200 || $d==true) { |
||
469 | if ($d == false) $d = true; |
||
470 | } else { |
||
471 | $history_output .= '['; |
||
472 | $history_output .= $spotter_history['longitude'].', '; |
||
473 | $history_output .= $spotter_history['latitude'].','; |
||
474 | $history_output .= $spotter_history['altitude']; |
||
475 | $history_output .= '],'; |
||
476 | |||
477 | } |
||
478 | } |
||
479 | if ($history_output != '') $output .= substr($history_output, 0, -1); |
||
480 | $output .= ']'; |
||
481 | $output .= '}'; |
||
482 | $output .= '},'; |
||
483 | |||
484 | } |
||
485 | */ |
||
486 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
||
487 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
||
488 | |||
489 | if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
||
490 | || (!isset($_COOKIE['flightpath']) |
||
491 | && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) |
||
492 | || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) |
||
493 | || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) { |
||
494 | if ($tracker) { |
||
495 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
||
496 | } elseif ($marine) { |
||
497 | $spotter_history_array = $MarineLive->getAllLiveMarineDataById($spotter_item['fammarine_id']); |
||
498 | } else { |
||
499 | if ($from_archive) { |
||
500 | $spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']); |
||
501 | } else { |
||
502 | $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']); |
||
503 | } |
||
504 | } |
||
505 | $d = false; |
||
506 | foreach ($spotter_history_array as $key => $spotter_history) |
||
507 | { |
||
508 | if (isset($spotter_history['altitude'])) { |
||
509 | $alt = round($spotter_history['altitude']/10)*10; |
||
510 | if (!isset($prev_alt) || $prev_alt != $alt) { |
||
511 | if (isset($prev_alt)) { |
||
512 | $output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']'; |
||
513 | $output_history .= ']}},'; |
||
514 | $output .= $output_history; |
||
515 | } |
||
516 | if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
||
517 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
||
518 | } |
||
519 | $output_history .= '['; |
||
520 | $output_history .= $spotter_history['longitude'].', '; |
||
521 | $output_history .= $spotter_history['latitude'].', '; |
||
522 | $output_history .= $spotter_history['altitude']*30.48; |
||
523 | $output_history .= '],'; |
||
524 | $prev_alt = $alt; |
||
525 | } else { |
||
526 | if ($d == false) { |
||
0 ignored issues
–
show
|
|||
527 | if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
||
528 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
||
529 | } else $d = true; |
||
530 | $output_history .= '['; |
||
531 | $output_history .= $spotter_history['longitude'].', '; |
||
532 | $output_history .= $spotter_history['latitude']; |
||
533 | $output_history .= '],'; |
||
534 | } |
||
535 | //} |
||
536 | } |
||
537 | if (isset($output_history)) { |
||
538 | $output_history = substr($output_history, 0, -1); |
||
539 | $output_history .= ']}},'; |
||
540 | $output .= $output_history; |
||
541 | unset($prev_alt); |
||
542 | unset($output_history); |
||
543 | } |
||
544 | } |
||
545 | |||
546 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
||
547 | $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
||
548 | if (isset($spotter_item['departure_airport_latitude'])) { |
||
549 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
||
550 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
||
551 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
||
552 | if (isset($dairport[0]['latitude'])) { |
||
553 | $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
||
554 | } |
||
555 | } |
||
556 | if (isset($spotter_item['arrival_airport_latitude'])) { |
||
557 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
||
558 | } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
||
559 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
||
560 | if (isset($aairport[0]['latitude'])) { |
||
561 | $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
||
562 | } |
||
563 | } |
||
564 | $output_air .= ']}},'; |
||
565 | $output .= $output_air; |
||
566 | unset($output_air); |
||
567 | } |
||
568 | } |
||
569 | $output = substr($output, 0, -1); |
||
570 | $output .= ']'; |
||
571 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
||
572 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
||
573 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
||
574 | $output .= '"fc": "'.$j.'"'; |
||
575 | } else { |
||
576 | $output .= '"features": '; |
||
577 | $output .= '{'; |
||
578 | $output .= '"type": "Feature",'; |
||
579 | $output .= '"properties": {'; |
||
580 | $output .= '"fc": "'.$flightcnt.'"}}'; |
||
581 | } |
||
582 | |||
583 | $output .= '}'; |
||
584 | |||
585 | print $output; |
||
586 | |||
587 | ?> |
||
588 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.