This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | |||
5 | if (isset($globalProtect) && $globalProtect) { |
||
6 | @session_start(); |
||
0 ignored issues
–
show
|
|||
7 | if (!isset($_SESSION['protect']) || !isset($_SERVER['HTTP_REFERER'])) { |
||
8 | echo 'You must access this page using the right way.'; |
||
9 | die(); |
||
10 | } |
||
11 | } |
||
12 | $tracker = false; |
||
13 | $marine = false; |
||
14 | $usecoord = false; |
||
15 | if (isset($_GET['test'])) exit(); |
||
16 | if (isset($_GET['tracker'])) { |
||
17 | $tracker = true; |
||
18 | } |
||
19 | if (isset($_GET['marine'])) { |
||
20 | $marine = true; |
||
21 | } |
||
22 | if ($tracker) { |
||
23 | require_once('require/class.Tracker.php'); |
||
24 | require_once('require/class.TrackerLive.php'); |
||
25 | require_once('require/class.TrackerArchive.php'); |
||
26 | } elseif ($marine) { |
||
27 | require_once('require/class.Marine.php'); |
||
28 | require_once('require/class.MarineLive.php'); |
||
29 | require_once('require/class.MarineArchive.php'); |
||
30 | } else { |
||
31 | require_once('require/class.Spotter.php'); |
||
32 | require_once('require/class.SpotterLive.php'); |
||
33 | require_once('require/class.SpotterArchive.php'); |
||
34 | } |
||
35 | |||
36 | $begintime = microtime(true); |
||
37 | if ($tracker) { |
||
38 | $TrackerLive = new TrackerLive(); |
||
39 | $Tracker = new Tracker(); |
||
40 | $TrackerArchive = new TrackerArchive(); |
||
41 | } elseif ($marine) { |
||
42 | $MarineLive = new MarineLive(); |
||
43 | $Marine = new Marine(); |
||
44 | $MarineArchive = new MarineArchive(); |
||
45 | } else { |
||
46 | $SpotterLive = new SpotterLive(); |
||
47 | $Spotter = new Spotter(); |
||
48 | $SpotterArchive = new SpotterArchive(); |
||
49 | } |
||
50 | $Common = new Common(); |
||
51 | |||
52 | if (isset($_GET['download'])) { |
||
53 | if ($_GET['download'] == "true") |
||
54 | { |
||
55 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
||
56 | } |
||
57 | } |
||
58 | header('Content-Type: text/javascript'); |
||
59 | |||
60 | if (!isset($globalJsonCompress)) $compress = true; |
||
61 | else $compress = $globalJsonCompress; |
||
62 | |||
63 | $limit = 0; |
||
64 | $from_archive = false; |
||
65 | $min = true; |
||
66 | $allhistory = false; |
||
67 | $filter['source'] = array(); |
||
68 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
||
69 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
||
70 | if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
||
71 | if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
||
72 | if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
||
73 | if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
||
74 | if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
||
75 | if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
||
76 | if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
||
77 | if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
||
78 | if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
||
79 | if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT); |
||
80 | if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true; |
||
81 | |||
82 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
||
83 | $min = true; |
||
84 | } else $min = false; |
||
85 | |||
86 | |||
87 | if (isset($_COOKIE['map_2d_limit'])) { |
||
88 | $limit = filter_var($_COOKIE['map_2d_limit'],FILTER_SANITIZE_NUMBER_INT); |
||
89 | } |
||
90 | |||
91 | $spotter_array = array(); |
||
92 | |||
93 | if (isset($_GET['ident'])) { |
||
94 | $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
||
95 | if ($tracker) { |
||
96 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
||
97 | } elseif ($marine) { |
||
98 | $spotter_array = $MarineLive->getLastLiveMarineDataByIdent($ident); |
||
99 | } else { |
||
100 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
||
101 | if (empty($spotter_array)) { |
||
102 | $from_archive = true; |
||
103 | $spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident); |
||
104 | } |
||
105 | } |
||
106 | $allhistory = true; |
||
107 | } elseif (isset($_GET['flightaware_id'])) { |
||
108 | $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
||
109 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
||
110 | if (empty($spotter_array)) { |
||
111 | $from_archive = true; |
||
112 | $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
||
113 | } |
||
114 | $allhistory = true; |
||
115 | } elseif (isset($_GET['famtrack_id'])) { |
||
116 | $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
||
117 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
||
118 | $allhistory = true; |
||
119 | } elseif (isset($_GET['fammarine_id'])) { |
||
120 | $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
||
121 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
||
122 | $allhistory = true; |
||
123 | /* |
||
124 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
||
125 | $usecoord = true; |
||
126 | $coord = explode(',',$_GET['coord']); |
||
127 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
||
128 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
||
129 | if ($tracker) { |
||
130 | $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
||
131 | } elseif ($marine) { |
||
132 | $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
||
133 | } else { |
||
134 | $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
||
135 | } |
||
136 | } |
||
137 | */ |
||
138 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) { |
||
139 | $usecoord = true; |
||
140 | $coord = explode(',',$_GET['coord']); |
||
141 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
||
142 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
||
143 | if ($tracker) { |
||
144 | $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
||
145 | } elseif ($marine) { |
||
146 | $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
||
147 | } else { |
||
148 | $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$limit,$filter); |
||
149 | } |
||
150 | } else { |
||
151 | if ($tracker) { |
||
152 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
||
153 | } elseif ($marine) { |
||
154 | $spotter_array = $MarineLive->getMinLiveMarineData($filter); |
||
155 | } else { |
||
156 | $spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter); |
||
157 | } |
||
158 | } |
||
159 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
||
160 | $from_archive = true; |
||
161 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
||
162 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
||
163 | $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
||
164 | $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
||
165 | $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
||
166 | $begindate = date('Y-m-d H:i:s',$begindate); |
||
167 | $enddate = date('Y-m-d H:i:s',$enddate); |
||
168 | $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
||
169 | } elseif ($min) { |
||
170 | if ($tracker) { |
||
171 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
||
172 | } elseif ($marine) { |
||
173 | $spotter_array = $MarineLive->getMinLiveMarineData($filter); |
||
174 | } else { |
||
175 | $spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter); |
||
176 | } |
||
177 | # $min = true; |
||
178 | } else { |
||
179 | if ($tracker) { |
||
180 | $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
||
181 | } elseif ($marine) { |
||
182 | $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
||
183 | } else { |
||
184 | $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
||
185 | } |
||
186 | } |
||
187 | |||
188 | if ($usecoord) { |
||
189 | if (isset($_GET['archive'])) { |
||
190 | $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
||
191 | } else { |
||
192 | if ($tracker) { |
||
193 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
||
194 | } elseif ($marine) { |
||
195 | $flightcnt = $MarineLive->getLiveMarineCount($filter); |
||
196 | } else { |
||
197 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
||
198 | } |
||
199 | } |
||
200 | if ($flightcnt == '') $flightcnt = 0; |
||
201 | } else $flightcnt = 0; |
||
202 | |||
203 | $sqltime = round(microtime(true)-$begintime,2); |
||
204 | |||
205 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
||
206 | if ($currenttime != '') $currenttime = round($currenttime/1000); |
||
207 | |||
208 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
||
209 | else $usenextlatlon = true; |
||
210 | if ($usenextlatlon === false) $currenttime = ''; |
||
211 | $j = 0; |
||
212 | $prev_flightaware_id = ''; |
||
213 | $aircrafts_shadow = array(); |
||
214 | $output = '{'; |
||
215 | $output .= '"type": "FeatureCollection",'; |
||
216 | if ($min) $output .= '"minimal": "true",'; |
||
217 | else $output .= '"minimal": "false",'; |
||
218 | //$output .= '"fc": "'.$flightcnt.'",'; |
||
219 | $output .= '"sqt": "'.$sqltime.'",'; |
||
220 | |||
221 | if (!empty($spotter_array) && is_array($spotter_array)) |
||
222 | { |
||
223 | $output .= '"features": ['; |
||
224 | foreach($spotter_array as $spotter_item) |
||
225 | { |
||
226 | $j++; |
||
227 | unset($idistance); |
||
228 | date_default_timezone_set('UTC'); |
||
229 | |||
230 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
||
231 | { |
||
232 | $image = $spotter_item['image_thumbnail']; |
||
233 | } else { |
||
234 | $image = "images/placeholder_thumb.png"; |
||
235 | } |
||
236 | |||
237 | /* |
||
238 | if ($prev_flightaware_id != $spotter_item['flightaware_id']) { |
||
239 | if ($prev_flightaware_id != '') { |
||
240 | $output .= ']'; |
||
241 | $output .= '}'; |
||
242 | $output .= '},'; |
||
243 | } |
||
244 | $prev_flightaware_id = $spotter_item['flightaware_id']; |
||
245 | */ |
||
246 | |||
247 | //location of aircraft |
||
248 | // print_r($spotter_item); |
||
249 | $output .= '{'; |
||
250 | $output .= '"type": "Feature",'; |
||
251 | //$output .= '"fc": "'.$flightcnt.'",'; |
||
252 | //$output .= '"sqt": "'.$sqltime.'",'; |
||
253 | if (isset($spotter_item['flightaware_id'])) { |
||
254 | $output .= '"id": "'.$spotter_item['flightaware_id'].'",'; |
||
255 | } elseif (isset($spotter_item['famtrackid'])) { |
||
256 | $output .= '"id": "'.$spotter_item['famtrackid'].'",'; |
||
257 | } elseif (isset($spotter_item['fammarine_id'])) { |
||
258 | $output .= '"id": "'.$spotter_item['fammarine_id'].'",'; |
||
259 | } |
||
260 | $output .= '"properties": {'; |
||
261 | if (isset($spotter_item['flightaware_id'])) { |
||
262 | if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
||
263 | else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
||
264 | } elseif (isset($spotter_item['famtrackid'])) { |
||
265 | if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
||
266 | else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
||
267 | } elseif (isset($spotter_item['fammarine_id'])) { |
||
268 | if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
||
269 | else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
||
270 | } |
||
271 | $output .= '"fc": "'.$flightcnt.'",'; |
||
272 | $output .= '"sqt": "'.$sqltime.'",'; |
||
273 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
||
274 | |||
275 | /* |
||
276 | if ($min) $output .= '"minimal": "true",'; |
||
277 | else $output .= '"minimal": "false",'; |
||
278 | */ |
||
279 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
||
280 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
||
281 | if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).','; |
||
282 | else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).','; |
||
283 | //' |
||
284 | } else { |
||
285 | if ($compress) $output .= '"c": "NA",'; |
||
286 | else $output .= '"callsign": "NA",'; |
||
287 | } |
||
288 | if (isset($spotter_item['registration'])) { |
||
289 | if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).','; |
||
290 | else $output .= '"registration": '.json_encode($spotter_item['registration']).','; |
||
291 | } |
||
292 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
||
293 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
||
294 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
||
295 | } elseif (isset($spotter_item['aircraft_type'])) { |
||
296 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
||
297 | } elseif (!$min) { |
||
298 | $output .= '"aircraft_name": "NA",'; |
||
299 | } |
||
300 | if (isset($spotter_item['aircraft_icao'])) { |
||
301 | if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",'; |
||
302 | else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
||
303 | } |
||
304 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) { |
||
305 | if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
||
306 | else { |
||
307 | $aircraft_icao = $spotter_item['aircraft_icao']; |
||
308 | if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
||
309 | else { |
||
310 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
||
311 | if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
||
312 | elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
||
313 | elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
||
314 | else $spotter_item['aircraft_shadow'] = ''; |
||
315 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
||
316 | } |
||
317 | } |
||
318 | } |
||
319 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
||
320 | if ($tracker) { |
||
321 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
||
322 | if ($compress) $output .= '"as": "ambulance.png",'; |
||
323 | else $output .= '"aircraft_shadow": "ambulance.png",'; |
||
324 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
||
325 | if ($compress) $output .= '"as": "police.png",'; |
||
326 | else $output .= '"aircraft_shadow": "police.png",'; |
||
327 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
||
328 | if ($compress) $output .= '"as": "ship.png",'; |
||
329 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
330 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
||
331 | if ($compress) $output .= '"as": "ship.png",'; |
||
332 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
333 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
||
334 | if ($compress) $output .= '"as": "ship.png",'; |
||
335 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
336 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
||
337 | if ($compress) $output .= '"as": "truck.png",'; |
||
338 | else $output .= '"aircraft_shadow": "truck.png",'; |
||
339 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
||
340 | if ($compress) $output .= '"as": "truck.png",'; |
||
341 | else $output .= '"aircraft_shadow": "truck.png",'; |
||
342 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
||
343 | if ($compress) $output .= '"as": "aircraft.png",'; |
||
344 | else $output .= '"aircraft_shadow": "aircraft.png",'; |
||
345 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
||
346 | if ($compress) $output .= '"as": "aircraft.png",'; |
||
347 | else $output .= '"aircraft_shadow": "aircraft.png",'; |
||
348 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
||
349 | if ($compress) $output .= '"as": "helico.png",'; |
||
350 | else $output .= '"aircraft_shadow": "helico.png",'; |
||
351 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
||
352 | if ($compress) $output .= '"as": "rail.png",'; |
||
353 | else $output .= '"aircraft_shadow": "rail.png",'; |
||
354 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
||
355 | if ($compress) $output .= '"as": "firetruck.png",'; |
||
356 | else $output .= '"aircraft_shadow": "firetruck.png",'; |
||
357 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
||
358 | if ($compress) $output .= '"as": "bus.png",'; |
||
359 | else $output .= '"aircraft_shadow": "bus.png",'; |
||
360 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
||
361 | if ($compress) $output .= '"as": "phone.png",'; |
||
362 | else $output .= '"aircraft_shadow": "phone.png",'; |
||
363 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
||
364 | if ($compress) $output .= '"as": "jogger.png",'; |
||
365 | else $output .= '"aircraft_shadow": "jogger.png",'; |
||
366 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
||
367 | if ($compress) $output .= '"as": "bike.png",'; |
||
368 | else $output .= '"aircraft_shadow": "bike.png",'; |
||
369 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
||
370 | if ($compress) $output .= '"as": "motorcycle.png",'; |
||
371 | else $output .= '"aircraft_shadow": "motorcycle.png",'; |
||
372 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
||
373 | if ($compress) $output .= '"as": "balloon.png",'; |
||
374 | else $output .= '"aircraft_shadow": "balloon.png",'; |
||
375 | } else { |
||
376 | if ($compress) $output .= '"as": "car.png",'; |
||
377 | else $output .= '"aircraft_shadow": "car.png",'; |
||
378 | } |
||
379 | } elseif ($marine) { |
||
380 | if (isset($spotter_item['type']) && ($spotter_item['type'] == '50' Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) { |
||
381 | if ($compress) $output .= '"as": "50perfcruiser.png",'; |
||
382 | else $output .= '"aircraft_shadow": "50perfcruiser.png",'; |
||
383 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') { |
||
384 | if ($compress) $output .= '"as": "cruiser38.png",'; |
||
385 | else $output .= '"aircraft_shadow": "cruiser38.png",'; |
||
386 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') { |
||
387 | if ($compress) $output .= '"as": "transat.png",'; |
||
388 | else $output .= '"aircraft_shadow": "transat.png",'; |
||
389 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52' Cruising Cat') { |
||
390 | if ($compress) $output .= '"as": "catamaran.png",'; |
||
391 | else $output .= '"aircraft_shadow": "catamaran.png",'; |
||
392 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') { |
||
393 | if ($compress) $output .= '"as": "carib.png",'; |
||
394 | else $output .= '"aircraft_shadow": "carib.png",'; |
||
395 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Nordic Folkboat') { |
||
396 | if ($compress) $output .= '"as": "nordic.png",'; |
||
397 | else $output .= '"aircraft_shadow": "nordic.png",'; |
||
398 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '32' Offshore Racer') { |
||
399 | if ($compress) $output .= '"as": "nordic.png",'; |
||
400 | else $output .= '"aircraft_shadow": "50perfcruiser.png",'; |
||
401 | } else { |
||
402 | if ($compress) $output .= '"as": "ship.png",'; |
||
403 | else $output .= '"aircraft_shadow": "ship.png",'; |
||
404 | } |
||
405 | } else { |
||
406 | if ($compress) $output .= '"as": "default.png",'; |
||
407 | else $output .= '"aircraft_shadow": "default.png",'; |
||
408 | } |
||
409 | } else { |
||
410 | if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
||
411 | else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
||
412 | } |
||
413 | if (isset($spotter_item['airline_name'])) { |
||
414 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
||
415 | } elseif (!$min) { |
||
416 | $output .= '"airline_name": "NA",'; |
||
417 | } |
||
418 | if (isset($spotter_item['departure_airport'])) { |
||
419 | if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
||
420 | else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
||
421 | } |
||
422 | if (isset($spotter_item['departure_airport_city'])) { |
||
423 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
||
424 | } |
||
425 | if (isset($spotter_item['departure_airport_time'])) { |
||
426 | $output .= '"departure_airport_time": "'.$spotter_item['departure_airport_time'].'",'; |
||
427 | } |
||
428 | if (isset($spotter_item['arrival_airport_time'])) { |
||
429 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
||
430 | } |
||
431 | if (isset($spotter_item['arrival_airport'])) { |
||
432 | if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
||
433 | else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
||
434 | } |
||
435 | if (isset($spotter_item['arrival_airport_city'])) { |
||
436 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
||
437 | } |
||
438 | |||
439 | if (isset($spotter_item['date_iso_8601'])) { |
||
440 | $output .= '"date_update": "'.date("M j, Y, g:i a T", strtotime($spotter_item['date_iso_8601'])).'",'; |
||
441 | $output .= '"lu": "'.strtotime($spotter_item['date_iso_8601']).'",'; |
||
442 | } elseif (isset($spotter_item['date'])) { |
||
443 | $output .= '"lu": "'.strtotime($spotter_item['date']).'",'; |
||
444 | } |
||
445 | if (!$min) { |
||
446 | $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
||
447 | $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
||
448 | $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
||
449 | } |
||
450 | |||
451 | if (isset($spotter_item['real_altitude'])) { |
||
452 | if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
||
453 | else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
||
454 | } elseif (isset($spotter_item['altitude'])) { |
||
455 | if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
||
456 | else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
||
457 | } |
||
458 | |||
459 | $heading = $spotter_item['heading']; |
||
460 | |||
461 | if (isset($archivespeed) || $usenextlatlon) { |
||
462 | if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
||
463 | if (isset($spotter_item['arrival_airport_latitude'])) { |
||
464 | $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
||
465 | $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
||
466 | $farr_lat = $spotter_item['arrival_airport_latitude']; |
||
467 | $farr_lon = $spotter_item['arrival_airport_longitude']; |
||
468 | } else { |
||
469 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
||
470 | if (isset($aairport[0]['latitude'])) { |
||
471 | $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
||
472 | $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
||
473 | $farr_lat = $aairport[0]['latitude']; |
||
474 | $farr_lon = $aairport[0]['longitude']; |
||
475 | } |
||
476 | } |
||
477 | } |
||
478 | } |
||
479 | |||
480 | if ($compress)$output .= '"h": "'.$heading.'",'; |
||
481 | else $output .= '"heading": "'.$heading.'",'; |
||
482 | if ($currenttime != '') { |
||
483 | if (strtotime($spotter_item['date']) < $currenttime) { |
||
484 | if (isset($archivespeed)) { |
||
485 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
||
486 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
487 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
488 | else { |
||
489 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
||
490 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
491 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
492 | else { |
||
493 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
||
494 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
495 | } |
||
496 | } |
||
497 | } elseif ($usenextlatlon) { |
||
498 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
||
499 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
500 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
501 | else { |
||
502 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
||
503 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
504 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
505 | else { |
||
506 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
||
507 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
508 | } |
||
509 | } |
||
510 | } |
||
511 | } else { |
||
512 | if (isset($archivespeed)) { |
||
513 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
||
514 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
515 | } elseif ($usenextlatlon) { |
||
516 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
||
517 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
518 | } |
||
519 | } |
||
520 | } else { |
||
521 | if (isset($archivespeed)) { |
||
522 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
||
523 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
524 | if (!isset($idistance) || $fdistance < $idistance) { |
||
525 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
526 | } else { |
||
527 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed); |
||
528 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
529 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
530 | } |
||
531 | } elseif ($usenextlatlon) { |
||
532 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
||
533 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
534 | if (!isset($idistance) || $fdistance < $idistance) { |
||
535 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
536 | } else { |
||
537 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading); |
||
538 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
539 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
||
540 | } |
||
541 | } |
||
542 | } |
||
543 | |||
544 | if (!$min) $output .= '"image": "'.$image.'",'; |
||
545 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
||
546 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
||
547 | } |
||
548 | if (isset($spotter_item['image_source_website'])) { |
||
549 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
||
550 | } |
||
551 | if (isset($spotter_item['squawk'])) { |
||
552 | if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
||
553 | else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
||
554 | } |
||
555 | if (isset($spotter_item['squawk_usage'])) { |
||
556 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
||
557 | } |
||
558 | if (isset($spotter_item['captain_name'])) { |
||
559 | $output .= '"cap": '.json_encode($spotter_item['captain_name']).','; |
||
560 | } |
||
561 | if (isset($spotter_item['race_id']) && $spotter_item['race_id'] != '') { |
||
562 | $output .= '"rid": '.$spotter_item['race_id'].','; |
||
563 | } |
||
564 | if (isset($spotter_item['race_rank']) && $spotter_item['race_rank'] != '') { |
||
565 | $output .= '"rrk": '.$spotter_item['race_rank'].','; |
||
566 | } |
||
567 | if (isset($spotter_item['race_name']) && $spotter_item['race_name'] != '') { |
||
568 | $output .= '"rname": '.json_encode($spotter_item['race_name']).','; |
||
569 | } |
||
570 | if (isset($spotter_item['pilot_id'])) { |
||
571 | $output .= '"pilot_id": "'.$spotter_item['pilot_id'].'",'; |
||
572 | } |
||
573 | if (isset($spotter_item['pilot_name'])) { |
||
574 | $output .= '"pilot_name": "'.$spotter_item['pilot_name'].'",'; |
||
575 | } |
||
576 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
||
577 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
||
578 | } |
||
579 | if (isset($spotter_item['acars'])) { |
||
580 | $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
||
581 | } |
||
582 | // type when not aircraft ? |
||
583 | if (isset($spotter_item['type'])) { |
||
584 | if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
||
585 | else $output .= '"type": "'.$spotter_item['type'].'"'; |
||
586 | } elseif ($marine) { |
||
587 | if ($compress) $output .= '"t": "ship"'; |
||
588 | else $output .= '"type": "ship"'; |
||
589 | } else { |
||
590 | if ($compress) $output .= '"t": "aircraft"'; |
||
591 | else $output .= '"type": "aircraft"'; |
||
592 | } |
||
593 | $output .= '},'; |
||
594 | $output .= '"geometry": {'; |
||
595 | $output .= '"type": "Point",'; |
||
596 | $output .= '"coordinates": ['; |
||
597 | if ($currenttime != '') { |
||
598 | if (strtotime($spotter_item['date']) < $currenttime) { |
||
599 | if (!isset($archivespeed)) $archivespeed = 1; |
||
600 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
||
601 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
602 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
||
603 | else { |
||
604 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
||
605 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
||
606 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
||
607 | else { |
||
608 | $output .= $spotter_item['longitude'].', '; |
||
609 | $output .= $spotter_item['latitude']; |
||
610 | } |
||
611 | } |
||
612 | /* |
||
613 | if (!isset($archivespeed)) $archivespeed = 1; |
||
614 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed,$currenttime-strtotime($spotter_item['date'])); |
||
615 | $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
||
616 | */ |
||
617 | } else { |
||
618 | $output .= $spotter_item['longitude'].', '; |
||
619 | $output .= $spotter_item['latitude']; |
||
620 | } |
||
621 | } else { |
||
622 | $output .= $spotter_item['longitude'].', '; |
||
623 | $output .= $spotter_item['latitude']; |
||
624 | } |
||
625 | /* |
||
626 | .', '; |
||
627 | $output .= $spotter_item['altitude']*30.48; |
||
628 | $output .= ', '.strtotime($spotter_item['date']); |
||
629 | */ |
||
630 | $output .= ']'; |
||
631 | $output .= '}'; |
||
632 | $output .= '},'; |
||
633 | |||
634 | /* } else { |
||
635 | $output .= ', '; |
||
636 | $output .= $spotter_item['longitude'].', '; |
||
637 | $output .= $spotter_item['latitude'].', '; |
||
638 | $output .= $spotter_item['altitude']*30.48; |
||
639 | $output .= ', '.strtotime($spotter_item['date']); |
||
640 | |||
641 | } |
||
642 | */ |
||
643 | |||
644 | /* |
||
645 | //previous location history of aircraft |
||
646 | $output .= '{'; |
||
647 | $output .= '"type": "Feature",'; |
||
648 | $output .= '"properties": {'; |
||
649 | $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
||
650 | $output .= '"type": "history"'; |
||
651 | $output .= '},'; |
||
652 | $output .= '"geometry": {'; |
||
653 | $output .= '"type": "LineString",'; |
||
654 | $output .= '"coordinates": ['; |
||
655 | //$spotter_history_array = SpotterLive::getAllLiveSpotterDataByIdent($spotter_item['ident']); |
||
656 | if ($from_archive) { |
||
657 | $spotter_history_array = SpotterArchive::getAllArchiveSpotterDataById($spotter_item['flightaware_id']); |
||
658 | } else { |
||
659 | $spotter_history_array = SpotterLive::getAllLiveSpotterDataById($spotter_item['flightaware_id']); |
||
660 | } |
||
661 | $d = false; |
||
662 | $neg = false; |
||
663 | $history_output = ''; |
||
664 | foreach ($spotter_history_array as $key => $spotter_history) |
||
665 | { |
||
666 | if (abs($spotter_history['longitude']-$spotter_item['longitude']) > 200 || $d==true) { |
||
667 | if ($d == false) $d = true; |
||
668 | } else { |
||
669 | $history_output .= '['; |
||
670 | $history_output .= $spotter_history['longitude'].', '; |
||
671 | $history_output .= $spotter_history['latitude'].','; |
||
672 | $history_output .= $spotter_history['altitude']; |
||
673 | $history_output .= '],'; |
||
674 | |||
675 | } |
||
676 | } |
||
677 | if ($history_output != '') $output .= substr($history_output, 0, -1); |
||
678 | $output .= ']'; |
||
679 | $output .= '}'; |
||
680 | $output .= '},'; |
||
681 | |||
682 | } |
||
683 | */ |
||
684 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
||
685 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
||
686 | |||
687 | if ( |
||
688 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
||
689 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
||
690 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
||
691 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
||
692 | || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
||
693 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
||
694 | || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
||
695 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
||
696 | || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
||
697 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
||
698 | ) { |
||
699 | if ($tracker) { |
||
700 | if ($from_archive || $globalArchive) { |
||
701 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
||
702 | } else { |
||
703 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
||
704 | } |
||
705 | if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || |
||
706 | (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && |
||
707 | isset($_GET['zoom']) && $_GET['zoom'] > 12 && |
||
708 | isset($spotter_item['type']) && ( |
||
709 | $spotter_item['type'] == 'Firetruck' || |
||
710 | $spotter_item['type'] == 'Ambulance' || |
||
711 | $spotter_item['type'] == 'Truck (18 Wheeler)' || |
||
712 | $spotter_item['type'] == 'Truck' || |
||
713 | $spotter_item['type'] == 'Mobile Satellite Station' || |
||
714 | $spotter_item['type'] == 'Van' || |
||
715 | $spotter_item['type'] == 'Police' || |
||
716 | $spotter_item['type'] == 'Bus' || |
||
717 | $spotter_item['type'] == 'Jeep' || |
||
718 | $spotter_item['type'] == 'Motorcycle' || |
||
719 | $spotter_item['type'] == 'Car' |
||
720 | ) |
||
721 | ) { |
||
722 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
||
723 | $MapMatching = new MapMatching(); |
||
724 | if (isset($spotter_item['date_iso_8601'])) { |
||
725 | $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601']))))); |
||
726 | } else { |
||
727 | $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date']))))); |
||
728 | } |
||
729 | $spotter_history_array = $MapMatching->match($spotter_history_array_mm); |
||
730 | } |
||
731 | } elseif ($marine) { |
||
732 | if ($from_archive || $globalArchive) { |
||
733 | $spotter_history_array = $MarineArchive->getAllArchiveMarineDataById($spotter_item['fammarine_id']); |
||
734 | } else { |
||
735 | $spotter_history_array = $MarineLive->getAllLiveMarineDataById($spotter_item['fammarine_id']); |
||
736 | } |
||
737 | } else { |
||
738 | if ($from_archive || $globalArchive) { |
||
739 | $spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']); |
||
740 | //print_r($spotter_history_array); |
||
741 | } else { |
||
742 | $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']); |
||
743 | } |
||
744 | } |
||
745 | $d = false; |
||
746 | foreach ($spotter_history_array as $key => $spotter_history) |
||
747 | { |
||
748 | if (isset($spotter_history['altitude'])) { |
||
749 | $alt = round($spotter_history['altitude']/10)*10; |
||
750 | if (!isset($prev_alt) || $prev_alt != $alt) { |
||
751 | if (isset($prev_alt)) { |
||
752 | $output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']'; |
||
753 | $output_history .= ']}},'; |
||
754 | $output .= $output_history; |
||
755 | } |
||
756 | if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
||
757 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
||
758 | } |
||
759 | $output_history .= '['; |
||
760 | $output_history .= $spotter_history['longitude'].', '; |
||
761 | $output_history .= $spotter_history['latitude'].', '; |
||
762 | $output_history .= $spotter_history['altitude']*30.48; |
||
763 | $output_history .= '],'; |
||
764 | /* |
||
765 | if ($from_archive === false) { |
||
766 | $output_history .= '['; |
||
767 | $output_history .= $spotter_item['longitude'].', '; |
||
768 | $output_history .= $spotter_item['latitude'].', '; |
||
769 | $output_history .= $spotter_item['altitude']*30.48; |
||
770 | $output_history .= '],'; |
||
771 | } |
||
772 | */ |
||
773 | $prev_alt = $alt; |
||
774 | } else { |
||
775 | if ($d === false) { |
||
776 | if ($compress) { |
||
777 | $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",'; |
||
778 | if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
||
779 | elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
||
780 | $output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
||
781 | } else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
||
782 | $d = true; |
||
783 | } |
||
784 | $output_history .= '['; |
||
785 | $output_history .= $spotter_history['longitude'].', '; |
||
786 | $output_history .= $spotter_history['latitude']; |
||
787 | $output_history .= '],'; |
||
788 | /* |
||
789 | if ($from_archive === false) { |
||
790 | $output_history .= '['; |
||
791 | $output_history .= $spotter_item['longitude'].', '; |
||
792 | $output_history .= $spotter_item['latitude']; |
||
793 | $output_history .= '],'; |
||
794 | } |
||
795 | */ |
||
796 | } |
||
797 | } |
||
798 | if (isset($output_history)) { |
||
799 | //echo $output_history; |
||
800 | if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) { |
||
801 | $output_historyd = '['; |
||
802 | $output_historyd .= $spotter_item['longitude'].', '; |
||
803 | $output_historyd .= $spotter_item['latitude']; |
||
804 | if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
||
805 | $output_historyd .= '],'; |
||
806 | //$output_history = $output_historyd.$output_history; |
||
807 | $output_history = $output_history.$output_historyd; |
||
808 | } elseif (isset($spotter_history_array[0]['mapmatching_engine'])) { |
||
809 | $last = array_pop($spotter_history_array); |
||
810 | $latitude = $last['latitude']; |
||
811 | $longitude = $last['longitude']; |
||
812 | $output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output); |
||
813 | } |
||
814 | |||
815 | $output_history = substr($output_history, 0, -1); |
||
816 | $output_history .= ']}},'; |
||
817 | $output .= $output_history; |
||
818 | unset($prev_alt); |
||
819 | unset($output_history); |
||
820 | } |
||
821 | |||
822 | } |
||
823 | |||
824 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
||
825 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
||
826 | && (isset($spotter_item['departure_airport']) |
||
827 | && $spotter_item['departure_airport'] != 'NA' |
||
828 | && isset($spotter_item['arrival_airport']) |
||
829 | && $spotter_item['arrival_airport'] != 'NA' |
||
830 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
||
831 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
||
832 | if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
||
833 | else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
||
834 | if (isset($spotter_item['departure_airport_latitude'])) { |
||
835 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
||
836 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
||
837 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
||
838 | if (isset($dairport[0]['latitude'])) { |
||
839 | $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
||
840 | } |
||
841 | } |
||
842 | if (isset($spotter_item['arrival_airport_latitude'])) { |
||
843 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],'; |
||
844 | } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
||
845 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
||
846 | if (isset($aairport[0]['latitude'])) { |
||
847 | $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
||
848 | } |
||
849 | } |
||
850 | $output_air = substr($output_air, 0, -1); |
||
851 | $output_air .= ']}},'; |
||
852 | $output .= $output_air; |
||
853 | unset($output_air); |
||
854 | } |
||
855 | |||
856 | //if (isset($history) && $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))))) { |
||
857 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
||
858 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
||
859 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
||
860 | && (isset($spotter_item['arrival_airport']) |
||
861 | && $spotter_item['arrival_airport'] != 'NA' |
||
862 | && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
||
863 | || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
||
864 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
||
865 | $havedata = false; |
||
866 | if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
||
867 | else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
||
868 | |||
869 | //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
||
870 | if (isset($spotter_item['arrival_airport_latitude'])) { |
||
871 | //$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
||
872 | $end_lon = $spotter_item['arrival_airport_longitude']; |
||
873 | $end_lat = $spotter_item['arrival_airport_latitude']; |
||
874 | $havedata = true; |
||
875 | } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
||
876 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
||
877 | if (isset($aairport[0]['latitude'])) { |
||
878 | //$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
||
879 | $end_lon = $aairport[0]['longitude']; |
||
880 | $end_lat = $aairport[0]['latitude']; |
||
881 | $havedata = true; |
||
882 | } |
||
883 | } |
||
884 | if ($havedata) { |
||
885 | $line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon); |
||
886 | foreach ($line[0] as $coord) { |
||
887 | $output_dest .= '['.$coord[0].','.$coord[1].'],'; |
||
888 | } |
||
889 | $output_dest = substr($output_dest, 0, -1); |
||
890 | } |
||
891 | $output_dest .= ']}},'; |
||
892 | if ($havedata) $output .= $output_dest; |
||
893 | unset($output_dest); |
||
894 | } |
||
895 | } |
||
896 | $output = substr($output, 0, -1); |
||
897 | $output .= ']'; |
||
898 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
||
899 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
||
900 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
||
901 | $output .= '"fc": "'.$j.'"'; |
||
902 | } else { |
||
903 | $output .= '"features": '; |
||
904 | $output .= '[{'; |
||
905 | $output .= '"type": "Feature",'; |
||
906 | $output .= '"properties": {'; |
||
907 | $output .= '"fc": "'.$flightcnt.'",'; |
||
908 | $output .= '"empty": "true"}'; |
||
909 | $output .= ',"geometry": {"type": "Point","coordinates": [0, 0]}'; |
||
910 | $output .= '}]'; |
||
911 | } |
||
912 | |||
913 | $output .= '}'; |
||
914 | |||
915 | print $output; |
||
916 | |||
917 | ?> |
||
918 |
If you suppress an error, we recommend checking for the error condition explicitly: