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