@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,20 +108,30 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
108 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
132 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
133 | + $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
134 | + } |
|
117 | 135 | } |
118 | 136 | $Spotter->db = null; |
119 | 137 | $Schedule->db = null; |
@@ -133,14 +151,18 @@ discard block |
||
133 | 151 | |
134 | 152 | public function checkAll() { |
135 | 153 | global $globalDebug, $globalNoImport; |
136 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
154 | + if ($globalDebug) { |
|
155 | + echo "Update last seen flights data...\n"; |
|
156 | + } |
|
137 | 157 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
138 | 158 | foreach ($this->all_flights as $key => $flight) { |
139 | 159 | if (isset($this->all_flights[$key]['id'])) { |
140 | 160 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
141 | 161 | $Spotter = new Spotter($this->db); |
142 | 162 | $real_arrival = $this->arrival($key); |
143 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
163 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
164 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
165 | + } |
|
144 | 166 | } |
145 | 167 | } |
146 | 168 | } |
@@ -148,24 +170,32 @@ discard block |
||
148 | 170 | |
149 | 171 | public function arrival($key) { |
150 | 172 | global $globalClosestMinDist, $globalDebug; |
151 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo 'Update arrival...'."\n"; |
|
175 | + } |
|
152 | 176 | $Spotter = new Spotter($this->db); |
153 | 177 | $airport_icao = ''; |
154 | 178 | $airport_time = ''; |
155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
179 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
180 | + $globalClosestMinDist = 50; |
|
181 | + } |
|
156 | 182 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
157 | 183 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
158 | 184 | if (isset($closestAirports[0])) { |
159 | 185 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
160 | 186 | $airport_icao = $closestAirports[0]['icao']; |
161 | 187 | $airport_time = $this->all_flights[$key]['datetime']; |
162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
188 | + if ($globalDebug) { |
|
189 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
190 | + } |
|
163 | 191 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
164 | 192 | foreach ($closestAirports as $airport) { |
165 | 193 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
166 | 194 | $airport_icao = $airport['icao']; |
167 | 195 | $airport_time = $this->all_flights[$key]['datetime']; |
168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
196 | + if ($globalDebug) { |
|
197 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
198 | + } |
|
169 | 199 | break; |
170 | 200 | } |
171 | 201 | } |
@@ -173,14 +203,20 @@ discard block |
||
173 | 203 | $airport_icao = $closestAirports[0]['icao']; |
174 | 204 | $airport_time = $this->all_flights[$key]['datetime']; |
175 | 205 | } else { |
176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
206 | + if ($globalDebug) { |
|
207 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
208 | + } |
|
177 | 209 | } |
178 | 210 | } else { |
179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
211 | + if ($globalDebug) { |
|
212 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
213 | + } |
|
180 | 214 | } |
181 | 215 | |
182 | 216 | } else { |
183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
217 | + if ($globalDebug) { |
|
218 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
219 | + } |
|
184 | 220 | } |
185 | 221 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
186 | 222 | } |
@@ -190,7 +226,9 @@ discard block |
||
190 | 226 | public function del() { |
191 | 227 | global $globalDebug, $globalNoImport, $globalNoDB; |
192 | 228 | // Delete old infos |
193 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
229 | + if ($globalDebug) { |
|
230 | + echo 'Delete old values and update latest data...'."\n"; |
|
231 | + } |
|
194 | 232 | foreach ($this->all_flights as $key => $flight) { |
195 | 233 | if (isset($flight['lastupdate'])) { |
196 | 234 | if ($flight['lastupdate'] < (time()-1800)) { |
@@ -204,17 +242,23 @@ discard block |
||
204 | 242 | global $globalDebug, $globalNoImport, $globalNoDB; |
205 | 243 | // Delete old infos |
206 | 244 | if (isset($this->all_flights[$key]['id'])) { |
207 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
247 | + } |
|
208 | 248 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
209 | 249 | $real_arrival = $this->arrival($key); |
210 | 250 | $Spotter = new Spotter($this->db); |
211 | 251 | $SpotterLive = new SpotterLive($this->db); |
212 | 252 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
213 | 253 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
214 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
254 | + if ($globalDebug && $result != 'success') { |
|
255 | + echo '!!! ERROR : '.$result."\n"; |
|
256 | + } |
|
215 | 257 | $this->all_flights[$key]['putinarchive'] = true; |
216 | 258 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
217 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
259 | + if ($globalDebug && $result != 'success') { |
|
260 | + echo '!!! ERROR : '.$result."\n"; |
|
261 | + } |
|
218 | 262 | } |
219 | 263 | $Spotter->db = null; |
220 | 264 | $SpotterLive->db = null; |
@@ -226,9 +270,13 @@ discard block |
||
226 | 270 | public function add($line) { |
227 | 271 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
228 | 272 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
229 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
230 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
231 | -/* |
|
273 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
274 | + $globalCoordMinChange = '0.01'; |
|
275 | + } |
|
276 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
277 | + $globalAircraftMaxUpdate = 3000; |
|
278 | + } |
|
279 | + /* |
|
232 | 280 | $Spotter = new Spotter(); |
233 | 281 | $dbc = $Spotter->db; |
234 | 282 | $SpotterLive = new SpotterLive($dbc); |
@@ -250,19 +298,28 @@ discard block |
||
250 | 298 | // SBS format is CSV format |
251 | 299 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
252 | 300 | //print_r($line); |
253 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
301 | + if (isset($line['hex'])) { |
|
302 | + $line['hex'] = strtoupper($line['hex']); |
|
303 | + } |
|
254 | 304 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
255 | 305 | |
256 | 306 | // Increment message number |
257 | 307 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
258 | 308 | $current_date = date('Y-m-d'); |
259 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
260 | - else $source = ''; |
|
261 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
309 | + if (isset($line['source_name'])) { |
|
310 | + $source = $line['source_name']; |
|
311 | + } else { |
|
312 | + $source = ''; |
|
313 | + } |
|
314 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
315 | + $source = $line['format_source']; |
|
316 | + } |
|
262 | 317 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
263 | 318 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
264 | 319 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
265 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
320 | + } else { |
|
321 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
322 | + } |
|
266 | 323 | } |
267 | 324 | |
268 | 325 | /* |
@@ -278,23 +335,38 @@ discard block |
||
278 | 335 | //$this->db = $dbc; |
279 | 336 | |
280 | 337 | //$hex = trim($line['hex']); |
281 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
282 | - else $id = trim($line['id']); |
|
338 | + if (!isset($line['id'])) { |
|
339 | + $id = trim($line['hex']); |
|
340 | + } else { |
|
341 | + $id = trim($line['id']); |
|
342 | + } |
|
283 | 343 | |
284 | 344 | if (!isset($this->all_flights[$id])) { |
285 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
345 | + if ($globalDebug) { |
|
346 | + echo 'New flight...'."\n"; |
|
347 | + } |
|
286 | 348 | $this->all_flights[$id] = array(); |
287 | 349 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
288 | 350 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
289 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
351 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
352 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
353 | + } |
|
290 | 354 | if (!isset($line['id'])) { |
291 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
292 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
355 | + if (!isset($globalDaemon)) { |
|
356 | + $globalDaemon = TRUE; |
|
357 | + } |
|
358 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
293 | 359 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
294 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
360 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
361 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
362 | + } |
|
295 | 363 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
296 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
297 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
364 | + } else { |
|
365 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
366 | + } |
|
367 | + if ($globalAllFlights !== FALSE) { |
|
368 | + $dataFound = true; |
|
369 | + } |
|
298 | 370 | } |
299 | 371 | if (isset($line['source_type']) && $line['source_type'] != '') { |
300 | 372 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -316,12 +388,20 @@ discard block |
||
316 | 388 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
317 | 389 | } |
318 | 390 | $Spotter->db = null; |
319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
320 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
391 | + if ($globalDebugTimeElapsed) { |
|
392 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
393 | + } |
|
394 | + if ($aircraft_icao != '') { |
|
395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
396 | + } |
|
321 | 397 | } |
322 | 398 | } |
323 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
324 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
399 | + if ($globalAllFlights !== FALSE) { |
|
400 | + $dataFound = true; |
|
401 | + } |
|
402 | + if ($globalDebug) { |
|
403 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
404 | + } |
|
325 | 405 | } |
326 | 406 | if (isset($line['id']) && !isset($line['hex'])) { |
327 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -330,7 +410,9 @@ discard block |
||
330 | 410 | $icao = $line['aircraft_icao']; |
331 | 411 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
332 | 412 | $Spotter = new Spotter($this->db); |
333 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
413 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
414 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
415 | + } |
|
334 | 416 | $Spotter->db = null; |
335 | 417 | } |
336 | 418 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -340,15 +422,24 @@ discard block |
||
340 | 422 | $Spotter = new Spotter($this->db); |
341 | 423 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
342 | 424 | $Spotter->db = null; |
343 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
425 | + if ($aircraft_icao != '') { |
|
426 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
427 | + } |
|
344 | 428 | } |
345 | 429 | } |
346 | 430 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
347 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
348 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
349 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
350 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
351 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
431 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
432 | + $aircraft_icao = 'GLID'; |
|
433 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
434 | + $aircraft_icao = 'UHEL'; |
|
435 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
436 | + $aircraft_icao = 'TOWPLANE'; |
|
437 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
438 | + $aircraft_icao = 'POWAIRC'; |
|
439 | + } |
|
440 | + if (isset($aircraft_icao)) { |
|
441 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
442 | + } |
|
352 | 443 | } |
353 | 444 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
354 | 445 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -358,8 +449,11 @@ discard block |
||
358 | 449 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
359 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
360 | 451 | } else { |
361 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
362 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
452 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
453 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
454 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
455 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
456 | + } |
|
363 | 457 | /* |
364 | 458 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
365 | 459 | print_r($this->all_flights[$id]); |
@@ -368,16 +462,22 @@ discard block |
||
368 | 462 | return ''; |
369 | 463 | } |
370 | 464 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
371 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
465 | + if ($globalDebug) { |
|
466 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
467 | + } |
|
372 | 468 | return ''; |
373 | 469 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
374 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
470 | + if ($globalDebug) { |
|
471 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
472 | + } |
|
375 | 473 | return ''; |
376 | 474 | } elseif (!isset($line['datetime'])) { |
377 | 475 | date_default_timezone_set('UTC'); |
378 | 476 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
379 | 477 | } else { |
380 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
478 | + if ($globalDebug) { |
|
479 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
480 | + } |
|
381 | 481 | return ''; |
382 | 482 | } |
383 | 483 | |
@@ -398,30 +498,48 @@ discard block |
||
398 | 498 | |
399 | 499 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
400 | 500 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
401 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
501 | + if ($globalDebug) { |
|
502 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
503 | + } |
|
402 | 504 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
403 | 505 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
404 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
405 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
406 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
506 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
508 | + } elseif (isset($line['id'])) { |
|
509 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
510 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
511 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
512 | + } |
|
407 | 513 | } else { |
408 | 514 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
409 | 515 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 516 | $timeelapsed = microtime(true); |
411 | 517 | $Spotter = new Spotter($this->db); |
412 | 518 | $fromsource = NULL; |
413 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
414 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
415 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
416 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
417 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
519 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
520 | + $fromsource = $globalAirlinesSource; |
|
521 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
522 | + $fromsource = 'vatsim'; |
|
523 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
524 | + $fromsource = 'ivao'; |
|
525 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
526 | + $fromsource = 'vatsim'; |
|
527 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
528 | + $fromsource = 'ivao'; |
|
529 | + } |
|
418 | 530 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
419 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
531 | + if ($globalDebug && $result != 'success') { |
|
532 | + echo '!!! ERROR : '.$result."\n"; |
|
533 | + } |
|
420 | 534 | $Spotter->db = null; |
421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + if ($globalDebugTimeElapsed) { |
|
536 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
537 | + } |
|
422 | 538 | } |
423 | 539 | } |
424 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
540 | + } else { |
|
541 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
542 | + } |
|
425 | 543 | |
426 | 544 | /* |
427 | 545 | if (!isset($line['id'])) { |
@@ -431,7 +549,9 @@ discard block |
||
431 | 549 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
432 | 550 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
433 | 551 | */ |
434 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
552 | + if (!isset($this->all_flights[$id]['id'])) { |
|
553 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
554 | + } |
|
435 | 555 | |
436 | 556 | //$putinarchive = true; |
437 | 557 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -449,7 +569,9 @@ discard block |
||
449 | 569 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
450 | 570 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
451 | 571 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
452 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
572 | + if ($globalDebugTimeElapsed) { |
|
573 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
574 | + } |
|
453 | 575 | } |
454 | 576 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
455 | 577 | $timeelapsed = microtime(true); |
@@ -463,7 +585,9 @@ discard block |
||
463 | 585 | $Translation->db = null; |
464 | 586 | } |
465 | 587 | $Spotter->db = null; |
466 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
588 | + if ($globalDebugTimeElapsed) { |
|
589 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
590 | + } |
|
467 | 591 | } |
468 | 592 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
469 | 593 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -472,9 +596,13 @@ discard block |
||
472 | 596 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
473 | 597 | } |
474 | 598 | } |
475 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
599 | + if (!isset($globalFork)) { |
|
600 | + $globalFork = TRUE; |
|
601 | + } |
|
476 | 602 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
477 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
603 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
604 | + $this->get_Schedule($id,trim($line['ident'])); |
|
605 | + } |
|
478 | 606 | } |
479 | 607 | } |
480 | 608 | } |
@@ -492,9 +620,13 @@ discard block |
||
492 | 620 | $speed = $speed*3.6; |
493 | 621 | if ($speed < 1000) { |
494 | 622 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
495 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
623 | + if ($globalDebug) { |
|
624 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
625 | + } |
|
496 | 626 | } else { |
497 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
627 | + if ($globalDebug) { |
|
628 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
629 | + } |
|
498 | 630 | } |
499 | 631 | } |
500 | 632 | } |
@@ -503,13 +635,21 @@ discard block |
||
503 | 635 | |
504 | 636 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
505 | 637 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
506 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
638 | + if ($globalDebug) { |
|
639 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
640 | + } |
|
507 | 641 | return false; |
508 | 642 | } |
509 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
510 | - else unset($timediff); |
|
511 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
512 | - else unset($timediff_archive); |
|
643 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
644 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
645 | + } else { |
|
646 | + unset($timediff); |
|
647 | + } |
|
648 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
649 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
650 | + } else { |
|
651 | + unset($timediff_archive); |
|
652 | + } |
|
513 | 653 | if ($this->tmd > 5 |
514 | 654 | || (isset($line['format_source']) |
515 | 655 | && $line['format_source'] == 'airwhere' |
@@ -546,16 +686,25 @@ discard block |
||
546 | 686 | $this->all_flights[$id]['putinarchive'] = true; |
547 | 687 | $this->tmd = 0; |
548 | 688 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
549 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
689 | + if ($globalDebug) { |
|
690 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
691 | + } |
|
550 | 692 | $timeelapsed = microtime(true); |
551 | 693 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
552 | 694 | $Spotter = new Spotter($this->db); |
553 | 695 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
554 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
555 | - else $this->all_flights[$id]['over_country'] = ''; |
|
696 | + if (!empty($all_country)) { |
|
697 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
698 | + } else { |
|
699 | + $this->all_flights[$id]['over_country'] = ''; |
|
700 | + } |
|
556 | 701 | $Spotter->db = null; |
557 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
558 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
702 | + if ($globalDebugTimeElapsed) { |
|
703 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
704 | + } |
|
705 | + if ($globalDebug) { |
|
706 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
707 | + } |
|
559 | 708 | } |
560 | 709 | } |
561 | 710 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -601,7 +750,9 @@ discard block |
||
601 | 750 | */ |
602 | 751 | } |
603 | 752 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
604 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
753 | + if ($line['longitude'] > 180) { |
|
754 | + $line['longitude'] = $line['longitude'] - 360; |
|
755 | + } |
|
605 | 756 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
606 | 757 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
607 | 758 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -638,7 +789,9 @@ discard block |
||
638 | 789 | } |
639 | 790 | } |
640 | 791 | if (isset($line['last_update']) && $line['last_update'] != '') { |
641 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
792 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
793 | + $dataFound = true; |
|
794 | + } |
|
642 | 795 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
643 | 796 | } |
644 | 797 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -660,35 +813,53 @@ discard block |
||
660 | 813 | // Here we force archive of flight because after ground it's a new one (or should be) |
661 | 814 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
662 | 815 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
663 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
664 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
665 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
816 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
817 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
818 | + } elseif (isset($line['id'])) { |
|
819 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
820 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
821 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
822 | + } |
|
823 | + } |
|
824 | + if ($line['ground'] != 1) { |
|
825 | + $line['ground'] = 0; |
|
666 | 826 | } |
667 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
668 | 827 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
669 | 828 | //$dataFound = true; |
670 | 829 | } |
671 | 830 | if (isset($line['squawk']) && $line['squawk'] != '') { |
672 | 831 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
673 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
832 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
833 | + $this->all_flights[$id]['putinarchive'] = true; |
|
834 | + } |
|
674 | 835 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
675 | 836 | $highlight = ''; |
676 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
677 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
678 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
837 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
838 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
839 | + } |
|
840 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
841 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
842 | + } |
|
843 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
844 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
845 | + } |
|
679 | 846 | if ($highlight != '') { |
680 | 847 | $timeelapsed = microtime(true); |
681 | 848 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
682 | 849 | $Spotter = new Spotter($this->db); |
683 | 850 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
684 | 851 | $Spotter->db = null; |
685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
852 | + if ($globalDebugTimeElapsed) { |
|
853 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
854 | + } |
|
686 | 855 | } |
687 | 856 | //$putinarchive = true; |
688 | 857 | //$highlight = ''; |
689 | 858 | } |
690 | 859 | |
691 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
860 | + } else { |
|
861 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
862 | + } |
|
692 | 863 | //$dataFound = true; |
693 | 864 | } |
694 | 865 | |
@@ -701,19 +872,27 @@ discard block |
||
701 | 872 | } |
702 | 873 | } |
703 | 874 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
704 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
875 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
876 | + $this->all_flights[$id]['putinarchive'] = true; |
|
877 | + } |
|
705 | 878 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
706 | 879 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
707 | 880 | //$dataFound = true; |
708 | 881 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
709 | 882 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
710 | 883 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
711 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
884 | + if ($globalDebug) { |
|
885 | + echo '--- Reset because of altitude'."\n"; |
|
886 | + } |
|
712 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
713 | 888 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
714 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
715 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
716 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
889 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
890 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
891 | + } elseif (isset($line['id'])) { |
|
892 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
893 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
894 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
895 | + } |
|
717 | 896 | } |
718 | 897 | } |
719 | 898 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -724,22 +903,32 @@ discard block |
||
724 | 903 | } |
725 | 904 | |
726 | 905 | if (isset($line['heading']) && $line['heading'] != '') { |
727 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
906 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
907 | + $this->all_flights[$id]['putinarchive'] = true; |
|
908 | + } |
|
728 | 909 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
729 | 910 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
730 | 911 | //$dataFound = true; |
731 | 912 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
732 | 913 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
733 | 914 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
734 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
915 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
916 | + $this->all_flights[$id]['putinarchive'] = true; |
|
917 | + } |
|
918 | + if ($globalDebug) { |
|
919 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
920 | + } |
|
736 | 921 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
737 | 922 | // If not enough messages and ACARS set heading to 0 |
738 | 923 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
739 | 924 | } |
740 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
741 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
742 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
925 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
926 | + $dataFound = false; |
|
927 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
928 | + $dataFound = false; |
|
929 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
930 | + $dataFound = false; |
|
931 | + } |
|
743 | 932 | |
744 | 933 | // print_r($this->all_flights[$id]); |
745 | 934 | //gets the callsign from the last hour |
@@ -756,23 +945,38 @@ discard block |
||
756 | 945 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
757 | 946 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
758 | 947 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
759 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
948 | + if ($globalDebug) { |
|
949 | + echo "Check if aircraft is already in DB..."; |
|
950 | + } |
|
760 | 951 | $timeelapsed = microtime(true); |
761 | 952 | $SpotterLive = new SpotterLive($this->db); |
762 | 953 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
763 | 954 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
764 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
955 | + if ($globalDebugTimeElapsed) { |
|
956 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
957 | + } |
|
765 | 958 | } elseif (isset($line['id'])) { |
766 | 959 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
767 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
960 | + if ($globalDebugTimeElapsed) { |
|
961 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
962 | + } |
|
768 | 963 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
769 | 964 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
770 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
771 | - } else $recent_ident = ''; |
|
965 | + if ($globalDebugTimeElapsed) { |
|
966 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
967 | + } |
|
968 | + } else { |
|
969 | + $recent_ident = ''; |
|
970 | + } |
|
772 | 971 | $SpotterLive->db=null; |
773 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
774 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
775 | - } else $recent_ident = ''; |
|
972 | + if ($globalDebug && $recent_ident == '') { |
|
973 | + echo " Not in DB.\n"; |
|
974 | + } elseif ($globalDebug && $recent_ident != '') { |
|
975 | + echo " Already in DB.\n"; |
|
976 | + } |
|
977 | + } else { |
|
978 | + $recent_ident = ''; |
|
979 | + } |
|
776 | 980 | } else { |
777 | 981 | $recent_ident = ''; |
778 | 982 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -780,7 +984,9 @@ discard block |
||
780 | 984 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
781 | 985 | if($recent_ident == "") |
782 | 986 | { |
783 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
987 | + if ($globalDebug) { |
|
988 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
989 | + } |
|
784 | 990 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
785 | 991 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
786 | 992 | //adds the spotter data for the archive |
@@ -824,10 +1030,18 @@ discard block |
||
824 | 1030 | |
825 | 1031 | if (!$ignoreImport) { |
826 | 1032 | $highlight = ''; |
827 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
828 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
829 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
830 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1033 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1034 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1035 | + } |
|
1036 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1037 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1038 | + } |
|
1039 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1040 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1041 | + } |
|
1042 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1043 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1044 | + } |
|
831 | 1045 | $timeelapsed = microtime(true); |
832 | 1046 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
833 | 1047 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -835,28 +1049,43 @@ discard block |
||
835 | 1049 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
836 | 1050 | $Spotter->db = null; |
837 | 1051 | if ($globalDebug) { |
838 | - if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
839 | - else echo 'Success'; |
|
1052 | + if (isset($result['error'])) { |
|
1053 | + echo 'Error: '.$result['error']."\n"; |
|
1054 | + } else { |
|
1055 | + echo 'Success'; |
|
1056 | + } |
|
840 | 1057 | } |
841 | 1058 | if (count($result) > 1) { |
842 | 1059 | // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
843 | - if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
844 | - if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
|
1060 | + if ($this->all_flights[$id]['aircraft_icao'] == '') { |
|
1061 | + $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
1062 | + } |
|
1063 | + if ($this->all_flights[$id]['registration'] == '') { |
|
1064 | + $this->all_flights[$id]['registration'] = $result[':registration']; |
|
1065 | + } |
|
845 | 1066 | } |
846 | 1067 | } |
847 | 1068 | } |
848 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1069 | + if ($globalDebugTimeElapsed) { |
|
1070 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1071 | + } |
|
849 | 1072 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
850 | 1073 | |
851 | 1074 | // Add source stat in DB |
852 | 1075 | $Stats = new Stats($this->db); |
853 | 1076 | if (!empty($this->stats)) { |
854 | - if ($globalDebug) echo 'Add source stats : '; |
|
1077 | + if ($globalDebug) { |
|
1078 | + echo 'Add source stats : '; |
|
1079 | + } |
|
855 | 1080 | foreach($this->stats as $date => $data) { |
856 | 1081 | foreach($data as $source => $sourced) { |
857 | 1082 | //print_r($sourced); |
858 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
859 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1083 | + if (isset($sourced['polar'])) { |
|
1084 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1085 | + } |
|
1086 | + if (isset($sourced['hist'])) { |
|
1087 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1088 | + } |
|
860 | 1089 | if (isset($sourced['msg'])) { |
861 | 1090 | if (time() - $sourced['msg']['date'] > 10) { |
862 | 1091 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -869,13 +1098,17 @@ discard block |
||
869 | 1098 | unset($this->stats[$date]); |
870 | 1099 | } |
871 | 1100 | } |
872 | - if ($globalDebug) echo 'Done'."\n"; |
|
1101 | + if ($globalDebug) { |
|
1102 | + echo 'Done'."\n"; |
|
1103 | + } |
|
873 | 1104 | |
874 | 1105 | } |
875 | 1106 | $Stats->db = null; |
876 | 1107 | } |
877 | 1108 | $this->del(); |
878 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1109 | + } elseif ($globalDebug) { |
|
1110 | + echo 'Ignore data'."\n"; |
|
1111 | + } |
|
879 | 1112 | //$ignoreImport = false; |
880 | 1113 | $this->all_flights[$id]['addedSpotter'] = 1; |
881 | 1114 | //print_r($this->all_flights[$id]); |
@@ -892,7 +1125,9 @@ discard block |
||
892 | 1125 | */ |
893 | 1126 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
894 | 1127 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
895 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1128 | + if ($globalDebug) { |
|
1129 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1130 | + } |
|
896 | 1131 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
897 | 1132 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
898 | 1133 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -901,7 +1136,9 @@ discard block |
||
901 | 1136 | $SpotterLive->db=null; |
902 | 1137 | } |
903 | 1138 | } |
904 | - if ($globalDebug) echo " Done\n"; |
|
1139 | + if ($globalDebug) { |
|
1140 | + echo " Done\n"; |
|
1141 | + } |
|
905 | 1142 | $this->last_delete = time(); |
906 | 1143 | } |
907 | 1144 | } else { |
@@ -928,11 +1165,17 @@ discard block |
||
928 | 1165 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
929 | 1166 | if ($globalDebug) { |
930 | 1167 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
931 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
932 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1168 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1169 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1170 | + } else { |
|
1171 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1172 | + } |
|
933 | 1173 | } else { |
934 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
935 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1174 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1175 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1176 | + } else { |
|
1177 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1178 | + } |
|
936 | 1179 | } |
937 | 1180 | } |
938 | 1181 | $ignoreImport = false; |
@@ -978,22 +1221,30 @@ discard block |
||
978 | 1221 | |
979 | 1222 | if (!$ignoreImport) { |
980 | 1223 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
981 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1224 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1225 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1226 | + } |
|
982 | 1227 | $timeelapsed = microtime(true); |
983 | 1228 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
984 | 1229 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
985 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1230 | + if ($globalDebug) { |
|
1231 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1232 | + } |
|
986 | 1233 | $SpotterLive = new SpotterLive($this->db); |
987 | 1234 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
988 | 1235 | $SpotterLive->db = null; |
989 | - if ($globalDebug) echo $result."\n"; |
|
1236 | + if ($globalDebug) { |
|
1237 | + echo $result."\n"; |
|
1238 | + } |
|
990 | 1239 | } |
991 | 1240 | } |
992 | 1241 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
993 | 1242 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
994 | 1243 | } |
995 | 1244 | $this->all_flights[$id]['putinarchive'] = false; |
996 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1245 | + if ($globalDebugTimeElapsed) { |
|
1246 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1247 | + } |
|
997 | 1248 | |
998 | 1249 | // Put statistics in $this->stats variable |
999 | 1250 | //if ($line['format_source'] != 'aprs') { |
@@ -1001,7 +1252,9 @@ discard block |
||
1001 | 1252 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1002 | 1253 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
1003 | 1254 | $source = $this->all_flights[$id]['source_name']; |
1004 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1255 | + if ($source == '') { |
|
1256 | + $source = $this->all_flights[$id]['format_source']; |
|
1257 | + } |
|
1005 | 1258 | if (!isset($this->source_location[$source])) { |
1006 | 1259 | $Location = new Source($this->db); |
1007 | 1260 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1022,7 +1275,9 @@ discard block |
||
1022 | 1275 | $stats_heading = round($stats_heading/22.5); |
1023 | 1276 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1024 | 1277 | $current_date = date('Y-m-d'); |
1025 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1278 | + if ($stats_heading == 16) { |
|
1279 | + $stats_heading = 0; |
|
1280 | + } |
|
1026 | 1281 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1027 | 1282 | for ($i=0;$i<=15;$i++) { |
1028 | 1283 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1040,7 +1295,9 @@ discard block |
||
1040 | 1295 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1041 | 1296 | end($this->stats[$current_date][$source]['hist']); |
1042 | 1297 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1043 | - } else $mini = 0; |
|
1298 | + } else { |
|
1299 | + $mini = 0; |
|
1300 | + } |
|
1044 | 1301 | for ($i=$mini;$i<=$distance;$i+=10) { |
1045 | 1302 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1046 | 1303 | } |
@@ -1052,19 +1309,27 @@ discard block |
||
1052 | 1309 | } |
1053 | 1310 | |
1054 | 1311 | $this->all_flights[$id]['lastupdate'] = time(); |
1055 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1312 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1313 | + $send = true; |
|
1314 | + } |
|
1056 | 1315 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1057 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1316 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1317 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1318 | + } |
|
1058 | 1319 | //$this->del(); |
1059 | 1320 | |
1060 | 1321 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1061 | 1322 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1062 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1323 | + if ($globalDebug) { |
|
1324 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1325 | + } |
|
1063 | 1326 | $SpotterLive = new SpotterLive($this->db); |
1064 | 1327 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1065 | 1328 | $SpotterLive->db = null; |
1066 | 1329 | //SpotterLive->deleteLiveSpotterData(); |
1067 | - if ($globalDebug) echo " Done\n"; |
|
1330 | + if ($globalDebug) { |
|
1331 | + echo " Done\n"; |
|
1332 | + } |
|
1068 | 1333 | $this->last_delete_hourly = time(); |
1069 | 1334 | } else { |
1070 | 1335 | $this->del(); |
@@ -1076,7 +1341,9 @@ discard block |
||
1076 | 1341 | //$ignoreImport = false; |
1077 | 1342 | } |
1078 | 1343 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1079 | - if ($send) return $this->all_flights[$id]; |
|
1344 | + if ($send) { |
|
1345 | + return $this->all_flights[$id]; |
|
1346 | + } |
|
1080 | 1347 | } |
1081 | 1348 | } |
1082 | 1349 | } |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -126,8 +130,11 @@ discard block |
||
126 | 130 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
127 | 131 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
128 | 132 | } |
129 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
130 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
133 | + if ($filter_query_where == '' && $where) { |
|
134 | + $filter_query_where = ' WHERE'; |
|
135 | + } elseif ($filter_query_where != '' && $and) { |
|
136 | + $filter_query_where .= ' AND'; |
|
137 | + } |
|
131 | 138 | if ($filter_query_where != '') { |
132 | 139 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
133 | 140 | } |
@@ -168,9 +175,13 @@ discard block |
||
168 | 175 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
169 | 176 | } |
170 | 177 | } |
171 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
178 | + if ($orderby_query == '') { |
|
179 | + $orderby_query = ' ORDER BY date DESC'; |
|
180 | + } |
|
172 | 181 | |
173 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
182 | + if (!isset($globalLiveInterval)) { |
|
183 | + $globalLiveInterval = '200'; |
|
184 | + } |
|
174 | 185 | if ($globalDBdriver == 'mysql') { |
175 | 186 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
176 | 187 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -193,7 +204,9 @@ discard block |
||
193 | 204 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
194 | 205 | date_default_timezone_set('UTC'); |
195 | 206 | $filter_query = $this->getFilter($filter,true,true); |
196 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
207 | + if (!isset($globalLiveInterval)) { |
|
208 | + $globalLiveInterval = '200'; |
|
209 | + } |
|
197 | 210 | if ($globalDBdriver == 'mysql') { |
198 | 211 | if (isset($globalArchive) && $globalArchive === TRUE) { |
199 | 212 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -244,8 +257,12 @@ discard block |
||
244 | 257 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
245 | 258 | $filter_query = $this->getFilter($filter,true,true); |
246 | 259 | |
247 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
248 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
260 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
261 | + $globalLiveInterval = '200'; |
|
262 | + } |
|
263 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
264 | + $globalMap3DAircraftsLimit = '300'; |
|
265 | + } |
|
249 | 266 | if ($globalDBdriver == 'mysql') { |
250 | 267 | if (isset($globalArchive) && $globalArchive === TRUE) { |
251 | 268 | /* |
@@ -256,25 +273,41 @@ discard block |
||
256 | 273 | */ |
257 | 274 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
258 | 275 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
259 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
260 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
276 | + if ($usecoord) { |
|
277 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
278 | + } |
|
279 | + if ($id != '') { |
|
280 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
281 | + } |
|
261 | 282 | $query .= "UNION |
262 | 283 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
263 | 284 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
264 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
265 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
285 | + if ($usecoord) { |
|
286 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
287 | + } |
|
288 | + if ($id != '') { |
|
289 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
290 | + } |
|
266 | 291 | $query .= ") AS spotter |
267 | 292 | WHERE latitude <> '0' AND longitude <> '0' |
268 | 293 | ORDER BY flightaware_id, date"; |
269 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
296 | + } |
|
270 | 297 | } else { |
271 | 298 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
272 | 299 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
273 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
274 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
300 | + if ($usecoord) { |
|
301 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
302 | + } |
|
303 | + if ($id != '') { |
|
304 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
305 | + } |
|
275 | 306 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
276 | 307 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
277 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
308 | + if ($limit) { |
|
309 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
310 | + } |
|
278 | 311 | } |
279 | 312 | } else { |
280 | 313 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -286,28 +319,46 @@ discard block |
||
286 | 319 | */ |
287 | 320 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
288 | 321 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
289 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
290 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
322 | + if ($usecoord) { |
|
323 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
324 | + } |
|
325 | + if ($id != '') { |
|
326 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
327 | + } |
|
291 | 328 | $query .= "UNION |
292 | 329 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
293 | 330 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
294 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
295 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
331 | + if ($usecoord) { |
|
332 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
333 | + } |
|
334 | + if ($id != '') { |
|
335 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
336 | + } |
|
296 | 337 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
297 | 338 | $query .= "ORDER BY flightaware_id, date"; |
298 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
339 | + if ($limit) { |
|
340 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
341 | + } |
|
299 | 342 | } else { |
300 | 343 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
301 | 344 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
302 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
303 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
345 | + if ($usecoord) { |
|
346 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
347 | + } |
|
348 | + if ($id != '') { |
|
349 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
350 | + } |
|
304 | 351 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
305 | 352 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
306 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
353 | + if ($limit) { |
|
354 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
355 | + } |
|
307 | 356 | } |
308 | 357 | } |
309 | 358 | $query_values = array(); |
310 | - if ($id != '') $query_values = array(':id' => $id); |
|
359 | + if ($id != '') { |
|
360 | + $query_values = array(':id' => $id); |
|
361 | + } |
|
311 | 362 | try { |
312 | 363 | $sth = $this->db->prepare($query); |
313 | 364 | $sth->execute($query_values); |
@@ -330,7 +381,9 @@ discard block |
||
330 | 381 | global $globalDBdriver, $globalLiveInterval; |
331 | 382 | $filter_query = $this->getFilter($filter,true,true); |
332 | 383 | |
333 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if (!isset($globalLiveInterval)) { |
|
385 | + $globalLiveInterval = '200'; |
|
386 | + } |
|
334 | 387 | if ($globalDBdriver == 'mysql') { |
335 | 388 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
336 | 389 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -360,7 +413,9 @@ discard block |
||
360 | 413 | { |
361 | 414 | global $globalDBdriver, $globalLiveInterval; |
362 | 415 | $Spotter = new Spotter($this->db); |
363 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
416 | + if (!isset($globalLiveInterval)) { |
|
417 | + $globalLiveInterval = '200'; |
|
418 | + } |
|
364 | 419 | $filter_query = $this->getFilter($filter); |
365 | 420 | |
366 | 421 | if (is_array($coord)) { |
@@ -368,7 +423,9 @@ discard block |
||
368 | 423 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
369 | 424 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
370 | 425 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
371 | - } else return array(); |
|
426 | + } else { |
|
427 | + return array(); |
|
428 | + } |
|
372 | 429 | if ($globalDBdriver == 'mysql') { |
373 | 430 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
374 | 431 | } else { |
@@ -389,7 +446,9 @@ discard block |
||
389 | 446 | { |
390 | 447 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
391 | 448 | $Spotter = new Spotter($this->db); |
392 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
449 | + if (!isset($globalLiveInterval)) { |
|
450 | + $globalLiveInterval = '200'; |
|
451 | + } |
|
393 | 452 | $filter_query = $this->getFilter($filter,true,true); |
394 | 453 | |
395 | 454 | if (is_array($coord)) { |
@@ -397,7 +456,9 @@ discard block |
||
397 | 456 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
398 | 457 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
399 | 458 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
400 | - } else return array(); |
|
459 | + } else { |
|
460 | + return array(); |
|
461 | + } |
|
401 | 462 | if ($globalDBdriver == 'mysql') { |
402 | 463 | if (isset($globalArchive) && $globalArchive === TRUE) { |
403 | 464 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -624,11 +685,15 @@ discard block |
||
624 | 685 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
625 | 686 | if ($globalDBdriver == 'mysql') { |
626 | 687 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
627 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
688 | + if ($liveinterval) { |
|
689 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
690 | + } |
|
628 | 691 | $query .= ' ORDER BY date'; |
629 | 692 | } else { |
630 | 693 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
631 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
694 | + if ($liveinterval) { |
|
695 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
696 | + } |
|
632 | 697 | $query .= ' ORDER BY date'; |
633 | 698 | } |
634 | 699 | |
@@ -723,7 +788,9 @@ discard block |
||
723 | 788 | $i++; |
724 | 789 | $j++; |
725 | 790 | if ($j == 30) { |
726 | - if ($globalDebug) echo "."; |
|
791 | + if ($globalDebug) { |
|
792 | + echo "."; |
|
793 | + } |
|
727 | 794 | try { |
728 | 795 | |
729 | 796 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1076,7 +1143,9 @@ discard block |
||
1076 | 1143 | { |
1077 | 1144 | return false; |
1078 | 1145 | } |
1079 | - } else return ''; |
|
1146 | + } else { |
|
1147 | + return ''; |
|
1148 | + } |
|
1080 | 1149 | |
1081 | 1150 | if ($longitude != '') |
1082 | 1151 | { |
@@ -1084,7 +1153,9 @@ discard block |
||
1084 | 1153 | { |
1085 | 1154 | return false; |
1086 | 1155 | } |
1087 | - } else return ''; |
|
1156 | + } else { |
|
1157 | + return ''; |
|
1158 | + } |
|
1088 | 1159 | |
1089 | 1160 | if ($waypoints != '') |
1090 | 1161 | { |
@@ -1100,14 +1171,18 @@ discard block |
||
1100 | 1171 | { |
1101 | 1172 | return false; |
1102 | 1173 | } |
1103 | - } else $altitude = 0; |
|
1174 | + } else { |
|
1175 | + $altitude = 0; |
|
1176 | + } |
|
1104 | 1177 | if ($altitude_real != '') |
1105 | 1178 | { |
1106 | 1179 | if (!is_numeric($altitude_real)) |
1107 | 1180 | { |
1108 | 1181 | return false; |
1109 | 1182 | } |
1110 | - } else $altitude_real = 0; |
|
1183 | + } else { |
|
1184 | + $altitude_real = 0; |
|
1185 | + } |
|
1111 | 1186 | |
1112 | 1187 | if ($heading != '') |
1113 | 1188 | { |
@@ -1115,7 +1190,9 @@ discard block |
||
1115 | 1190 | { |
1116 | 1191 | return false; |
1117 | 1192 | } |
1118 | - } else $heading = 0; |
|
1193 | + } else { |
|
1194 | + $heading = 0; |
|
1195 | + } |
|
1119 | 1196 | |
1120 | 1197 | if ($groundspeed != '') |
1121 | 1198 | { |
@@ -1123,9 +1200,13 @@ discard block |
||
1123 | 1200 | { |
1124 | 1201 | return false; |
1125 | 1202 | } |
1126 | - } else $groundspeed = 0; |
|
1203 | + } else { |
|
1204 | + $groundspeed = 0; |
|
1205 | + } |
|
1127 | 1206 | date_default_timezone_set('UTC'); |
1128 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1207 | + if ($date == '') { |
|
1208 | + $date = date("Y-m-d H:i:s", time()); |
|
1209 | + } |
|
1129 | 1210 | |
1130 | 1211 | |
1131 | 1212 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1170,14 +1251,24 @@ discard block |
||
1170 | 1251 | $arrival_airport_country = ''; |
1171 | 1252 | |
1172 | 1253 | |
1173 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1174 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1175 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1176 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1254 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1255 | + $squawk = NULL; |
|
1256 | + } |
|
1257 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1258 | + $verticalrate = NULL; |
|
1259 | + } |
|
1260 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1261 | + $groundspeed = 0; |
|
1262 | + } |
|
1263 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1264 | + $heading = 0; |
|
1265 | + } |
|
1177 | 1266 | |
1178 | 1267 | $query = ''; |
1179 | 1268 | if ($globalArchive) { |
1180 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1269 | + if ($globalDebug) { |
|
1270 | + echo '-- Delete previous data -- '; |
|
1271 | + } |
|
1181 | 1272 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1182 | 1273 | } |
1183 | 1274 | |
@@ -1194,10 +1285,14 @@ discard block |
||
1194 | 1285 | return "error : ".$e->getMessage(); |
1195 | 1286 | } |
1196 | 1287 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1197 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1288 | + if ($globalDebug) { |
|
1289 | + echo '(Add to SBS archive : '; |
|
1290 | + } |
|
1198 | 1291 | $SpotterArchive = new SpotterArchive($this->db); |
1199 | 1292 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1200 | - if ($globalDebug) echo $result.')'; |
|
1293 | + if ($globalDebug) { |
|
1294 | + echo $result.')'; |
|
1295 | + } |
|
1201 | 1296 | } elseif ($globalDebug && $putinarchive !== true) { |
1202 | 1297 | echo '(Not adding to archive)'; |
1203 | 1298 | } elseif ($globalDebug && $noarchive === true) { |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | $tracker = false; |
13 | 13 | $marine = false; |
14 | 14 | $usecoord = false; |
15 | -if (isset($_GET['test'])) exit(); |
|
15 | +if (isset($_GET['test'])) { |
|
16 | + exit(); |
|
17 | +} |
|
16 | 18 | if (isset($_GET['tracker'])) { |
17 | 19 | $tracker = true; |
18 | 20 | } |
@@ -57,28 +59,55 @@ discard block |
||
57 | 59 | } |
58 | 60 | header('Content-Type: text/javascript'); |
59 | 61 | |
60 | -if (!isset($globalJsonCompress)) $compress = true; |
|
61 | -else $compress = $globalJsonCompress; |
|
62 | +if (!isset($globalJsonCompress)) { |
|
63 | + $compress = true; |
|
64 | +} else { |
|
65 | + $compress = $globalJsonCompress; |
|
66 | +} |
|
62 | 67 | |
63 | 68 | $from_archive = false; |
64 | 69 | $min = true; |
65 | 70 | $allhistory = false; |
66 | 71 | $filter['source'] = array(); |
67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
73 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
74 | +} |
|
75 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
76 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
77 | +} |
|
78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
79 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
80 | +} |
|
81 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
82 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
83 | +} |
|
84 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
85 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
86 | +} |
|
87 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
88 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
89 | +} |
|
90 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') { |
|
91 | + $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
92 | +} |
|
93 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
94 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
95 | +} |
|
96 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
97 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
98 | +} |
|
99 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
100 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
101 | +} |
|
102 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
103 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
104 | +} |
|
78 | 105 | |
79 | 106 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
80 | 107 | $min = true; |
81 | -} else $min = false; |
|
108 | +} else { |
|
109 | + $min = false; |
|
110 | +} |
|
82 | 111 | |
83 | 112 | $spotter_array = array(); |
84 | 113 | |
@@ -189,24 +218,38 @@ discard block |
||
189 | 218 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
190 | 219 | } |
191 | 220 | } |
192 | - if ($flightcnt == '') $flightcnt = 0; |
|
193 | -} else $flightcnt = 0; |
|
221 | + if ($flightcnt == '') { |
|
222 | + $flightcnt = 0; |
|
223 | + } |
|
224 | + } else { |
|
225 | + $flightcnt = 0; |
|
226 | +} |
|
194 | 227 | |
195 | 228 | $sqltime = round(microtime(true)-$begintime,2); |
196 | 229 | |
197 | 230 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
198 | -if ($currenttime != '') $currenttime = round($currenttime/1000); |
|
231 | +if ($currenttime != '') { |
|
232 | + $currenttime = round($currenttime/1000); |
|
233 | +} |
|
199 | 234 | |
200 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
201 | -else $usenextlatlon = true; |
|
202 | -if ($usenextlatlon === false) $currenttime = ''; |
|
235 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
236 | + $usenextlatlon = false; |
|
237 | +} else { |
|
238 | + $usenextlatlon = true; |
|
239 | +} |
|
240 | +if ($usenextlatlon === false) { |
|
241 | + $currenttime = ''; |
|
242 | +} |
|
203 | 243 | $j = 0; |
204 | 244 | $prev_flightaware_id = ''; |
205 | 245 | $aircrafts_shadow = array(); |
206 | 246 | $output = '{'; |
207 | 247 | $output .= '"type": "FeatureCollection",'; |
208 | - if ($min) $output .= '"minimal": "true",'; |
|
209 | - else $output .= '"minimal": "false",'; |
|
248 | + if ($min) { |
|
249 | + $output .= '"minimal": "true",'; |
|
250 | + } else { |
|
251 | + $output .= '"minimal": "false",'; |
|
252 | + } |
|
210 | 253 | //$output .= '"fc": "'.$flightcnt.'",'; |
211 | 254 | $output .= '"sqt": "'.$sqltime.'",'; |
212 | 255 | |
@@ -251,18 +294,29 @@ discard block |
||
251 | 294 | } |
252 | 295 | $output .= '"properties": {'; |
253 | 296 | if (isset($spotter_item['flightaware_id'])) { |
254 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
255 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
297 | + if ($compress) { |
|
298 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
299 | + } else { |
|
300 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
301 | + } |
|
256 | 302 | } elseif (isset($spotter_item['famtrackid'])) { |
257 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
258 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
303 | + if ($compress) { |
|
304 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
305 | + } else { |
|
306 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
307 | + } |
|
259 | 308 | } elseif (isset($spotter_item['fammarine_id'])) { |
260 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
261 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
309 | + if ($compress) { |
|
310 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
311 | + } else { |
|
312 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
313 | + } |
|
262 | 314 | } |
263 | 315 | $output .= '"fc": "'.$flightcnt.'",'; |
264 | 316 | $output .= '"sqt": "'.$sqltime.'",'; |
265 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
317 | + if (isset($begindate)) { |
|
318 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
319 | + } |
|
266 | 320 | |
267 | 321 | /* |
268 | 322 | if ($min) $output .= '"minimal": "true",'; |
@@ -270,16 +324,25 @@ discard block |
||
270 | 324 | */ |
271 | 325 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
272 | 326 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
273 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
274 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
327 | + if ($compress) { |
|
328 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
329 | + } else { |
|
330 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
331 | + } |
|
275 | 332 | //" |
276 | 333 | } else { |
277 | - if ($compress) $output .= '"c": "NA",'; |
|
278 | - else $output .= '"callsign": "NA",'; |
|
334 | + if ($compress) { |
|
335 | + $output .= '"c": "NA",'; |
|
336 | + } else { |
|
337 | + $output .= '"callsign": "NA",'; |
|
338 | + } |
|
279 | 339 | } |
280 | 340 | if (isset($spotter_item['registration'])) { |
281 | - if ($compress) $output .= '"reg": "'.$spotter_item['registration'].'",'; |
|
282 | - else $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
341 | + if ($compress) { |
|
342 | + $output .= '"reg": "'.$spotter_item['registration'].'",'; |
|
343 | + } else { |
|
344 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
345 | + } |
|
283 | 346 | } |
284 | 347 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
285 | 348 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
@@ -290,20 +353,30 @@ discard block |
||
290 | 353 | $output .= '"aircraft_name": "NA",'; |
291 | 354 | } |
292 | 355 | if (isset($spotter_item['aircraft_icao'])) { |
293 | - if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",'; |
|
294 | - else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
356 | + if ($compress) { |
|
357 | + $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",'; |
|
358 | + } else { |
|
359 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
360 | + } |
|
295 | 361 | } |
296 | 362 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) { |
297 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
298 | - else { |
|
363 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
364 | + $spotter_item['aircraft_shadow'] = ''; |
|
365 | + } else { |
|
299 | 366 | $aircraft_icao = $spotter_item['aircraft_icao']; |
300 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
301 | - else { |
|
367 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
368 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
369 | + } else { |
|
302 | 370 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
303 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
304 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
305 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
306 | - else $spotter_item['aircraft_shadow'] = ''; |
|
371 | + if (count($aircraft_info) > 0) { |
|
372 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
373 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
374 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
375 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
376 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
377 | + } else { |
|
378 | + $spotter_item['aircraft_shadow'] = ''; |
|
379 | + } |
|
307 | 380 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
308 | 381 | } |
309 | 382 | } |
@@ -311,73 +384,139 @@ discard block |
||
311 | 384 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
312 | 385 | if ($tracker) { |
313 | 386 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
314 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
315 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
387 | + if ($compress) { |
|
388 | + $output .= '"as": "ambulance.png",'; |
|
389 | + } else { |
|
390 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
391 | + } |
|
316 | 392 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
317 | - if ($compress) $output .= '"as": "police.png",'; |
|
318 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
393 | + if ($compress) { |
|
394 | + $output .= '"as": "police.png",'; |
|
395 | + } else { |
|
396 | + $output .= '"aircraft_shadow": "police.png",'; |
|
397 | + } |
|
319 | 398 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
320 | - if ($compress) $output .= '"as": "ship.png",'; |
|
321 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
399 | + if ($compress) { |
|
400 | + $output .= '"as": "ship.png",'; |
|
401 | + } else { |
|
402 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
403 | + } |
|
322 | 404 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
323 | - if ($compress) $output .= '"as": "ship.png",'; |
|
324 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
405 | + if ($compress) { |
|
406 | + $output .= '"as": "ship.png",'; |
|
407 | + } else { |
|
408 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
409 | + } |
|
325 | 410 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
326 | - if ($compress) $output .= '"as": "ship.png",'; |
|
327 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
411 | + if ($compress) { |
|
412 | + $output .= '"as": "ship.png",'; |
|
413 | + } else { |
|
414 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
415 | + } |
|
328 | 416 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
329 | - if ($compress) $output .= '"as": "truck.png",'; |
|
330 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
417 | + if ($compress) { |
|
418 | + $output .= '"as": "truck.png",'; |
|
419 | + } else { |
|
420 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
421 | + } |
|
331 | 422 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
332 | - if ($compress) $output .= '"as": "truck.png",'; |
|
333 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
423 | + if ($compress) { |
|
424 | + $output .= '"as": "truck.png",'; |
|
425 | + } else { |
|
426 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
427 | + } |
|
334 | 428 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
335 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
336 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
429 | + if ($compress) { |
|
430 | + $output .= '"as": "aircraft.png",'; |
|
431 | + } else { |
|
432 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
433 | + } |
|
337 | 434 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
338 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
339 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
435 | + if ($compress) { |
|
436 | + $output .= '"as": "aircraft.png",'; |
|
437 | + } else { |
|
438 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
439 | + } |
|
340 | 440 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
341 | - if ($compress) $output .= '"as": "helico.png",'; |
|
342 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
441 | + if ($compress) { |
|
442 | + $output .= '"as": "helico.png",'; |
|
443 | + } else { |
|
444 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
445 | + } |
|
343 | 446 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
344 | - if ($compress) $output .= '"as": "rail.png",'; |
|
345 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
447 | + if ($compress) { |
|
448 | + $output .= '"as": "rail.png",'; |
|
449 | + } else { |
|
450 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
451 | + } |
|
346 | 452 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
347 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
348 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
453 | + if ($compress) { |
|
454 | + $output .= '"as": "firetruck.png",'; |
|
455 | + } else { |
|
456 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
457 | + } |
|
349 | 458 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
350 | - if ($compress) $output .= '"as": "bus.png",'; |
|
351 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
459 | + if ($compress) { |
|
460 | + $output .= '"as": "bus.png",'; |
|
461 | + } else { |
|
462 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
463 | + } |
|
352 | 464 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
353 | - if ($compress) $output .= '"as": "phone.png",'; |
|
354 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
465 | + if ($compress) { |
|
466 | + $output .= '"as": "phone.png",'; |
|
467 | + } else { |
|
468 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
469 | + } |
|
355 | 470 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
356 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
357 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
471 | + if ($compress) { |
|
472 | + $output .= '"as": "jogger.png",'; |
|
473 | + } else { |
|
474 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
475 | + } |
|
358 | 476 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
359 | - if ($compress) $output .= '"as": "bike.png",'; |
|
360 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
477 | + if ($compress) { |
|
478 | + $output .= '"as": "bike.png",'; |
|
479 | + } else { |
|
480 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
481 | + } |
|
361 | 482 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
362 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
363 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
483 | + if ($compress) { |
|
484 | + $output .= '"as": "motorcycle.png",'; |
|
485 | + } else { |
|
486 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
487 | + } |
|
364 | 488 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
365 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
366 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
489 | + if ($compress) { |
|
490 | + $output .= '"as": "balloon.png",'; |
|
491 | + } else { |
|
492 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
493 | + } |
|
367 | 494 | } else { |
368 | - if ($compress) $output .= '"as": "car.png",'; |
|
369 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
495 | + if ($compress) { |
|
496 | + $output .= '"as": "car.png",'; |
|
497 | + } else { |
|
498 | + $output .= '"aircraft_shadow": "car.png",'; |
|
499 | + } |
|
370 | 500 | } |
371 | 501 | } elseif ($marine) { |
372 | - if ($compress) $output .= '"as": "ship.png",'; |
|
373 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
502 | + if ($compress) { |
|
503 | + $output .= '"as": "ship.png",'; |
|
504 | + } else { |
|
505 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
506 | + } |
|
374 | 507 | } else { |
375 | - if ($compress) $output .= '"as": "default.png",'; |
|
376 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
508 | + if ($compress) { |
|
509 | + $output .= '"as": "default.png",'; |
|
510 | + } else { |
|
511 | + $output .= '"aircraft_shadow": "default.png",'; |
|
512 | + } |
|
377 | 513 | } |
378 | 514 | } else { |
379 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
380 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
515 | + if ($compress) { |
|
516 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
517 | + } else { |
|
518 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
519 | + } |
|
381 | 520 | } |
382 | 521 | if (isset($spotter_item['airline_name'])) { |
383 | 522 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -385,8 +524,11 @@ discard block |
||
385 | 524 | $output .= '"airline_name": "NA",'; |
386 | 525 | } |
387 | 526 | if (isset($spotter_item['departure_airport'])) { |
388 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
389 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
527 | + if ($compress) { |
|
528 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
529 | + } else { |
|
530 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
531 | + } |
|
390 | 532 | } |
391 | 533 | if (isset($spotter_item['departure_airport_city'])) { |
392 | 534 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -398,8 +540,11 @@ discard block |
||
398 | 540 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
399 | 541 | } |
400 | 542 | if (isset($spotter_item['arrival_airport'])) { |
401 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
402 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
543 | + if ($compress) { |
|
544 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
545 | + } else { |
|
546 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
547 | + } |
|
403 | 548 | } |
404 | 549 | if (isset($spotter_item['arrival_airport_city'])) { |
405 | 550 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -418,11 +563,17 @@ discard block |
||
418 | 563 | } |
419 | 564 | |
420 | 565 | if (isset($spotter_item['real_altitude'])) { |
421 | - if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
422 | - else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
566 | + if ($compress) { |
|
567 | + $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
568 | + } else { |
|
569 | + $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
570 | + } |
|
423 | 571 | } elseif (isset($spotter_item['altitude'])) { |
424 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
425 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
572 | + if ($compress) { |
|
573 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
574 | + } else { |
|
575 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
576 | + } |
|
426 | 577 | } |
427 | 578 | |
428 | 579 | $heading = $spotter_item['heading']; |
@@ -446,19 +597,24 @@ discard block |
||
446 | 597 | } |
447 | 598 | } |
448 | 599 | |
449 | - if ($compress)$output .= '"h": "'.$heading.'",'; |
|
450 | - else $output .= '"heading": "'.$heading.'",'; |
|
600 | + if ($compress) { |
|
601 | + $output .= '"h": "'.$heading.'",'; |
|
602 | + } else { |
|
603 | + $output .= '"heading": "'.$heading.'",'; |
|
604 | + } |
|
451 | 605 | if ($currenttime != '') { |
452 | 606 | if (strtotime($spotter_item['date']) < $currenttime) { |
453 | 607 | if (isset($archivespeed)) { |
454 | 608 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
455 | 609 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
456 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
457 | - else { |
|
610 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
611 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
612 | + } else { |
|
458 | 613 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
459 | 614 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
460 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
461 | - else { |
|
615 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
616 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
617 | + } else { |
|
462 | 618 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
463 | 619 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
464 | 620 | } |
@@ -466,12 +622,14 @@ discard block |
||
466 | 622 | } elseif ($usenextlatlon) { |
467 | 623 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
468 | 624 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
469 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
470 | - else { |
|
625 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
626 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
627 | + } else { |
|
471 | 628 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
472 | 629 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
473 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
474 | - else { |
|
630 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
631 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
632 | + } else { |
|
475 | 633 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
476 | 634 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
477 | 635 | } |
@@ -510,7 +668,9 @@ discard block |
||
510 | 668 | } |
511 | 669 | } |
512 | 670 | |
513 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
671 | + if (!$min) { |
|
672 | + $output .= '"image": "'.$image.'",'; |
|
673 | + } |
|
514 | 674 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
515 | 675 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
516 | 676 | } |
@@ -518,8 +678,11 @@ discard block |
||
518 | 678 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
519 | 679 | } |
520 | 680 | if (isset($spotter_item['squawk'])) { |
521 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
522 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
681 | + if ($compress) { |
|
682 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
683 | + } else { |
|
684 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
685 | + } |
|
523 | 686 | } |
524 | 687 | if (isset($spotter_item['squawk_usage'])) { |
525 | 688 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -538,14 +701,23 @@ discard block |
||
538 | 701 | } |
539 | 702 | // type when not aircraft ? |
540 | 703 | if (isset($spotter_item['type'])) { |
541 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
542 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
704 | + if ($compress) { |
|
705 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
706 | + } else { |
|
707 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
708 | + } |
|
543 | 709 | } elseif ($marine) { |
544 | - if ($compress) $output .= '"t": "ship"'; |
|
545 | - else $output .= '"type": "ship"'; |
|
710 | + if ($compress) { |
|
711 | + $output .= '"t": "ship"'; |
|
712 | + } else { |
|
713 | + $output .= '"type": "ship"'; |
|
714 | + } |
|
546 | 715 | } else { |
547 | - if ($compress) $output .= '"t": "aircraft"'; |
|
548 | - else $output .= '"type": "aircraft"'; |
|
716 | + if ($compress) { |
|
717 | + $output .= '"t": "aircraft"'; |
|
718 | + } else { |
|
719 | + $output .= '"type": "aircraft"'; |
|
720 | + } |
|
549 | 721 | } |
550 | 722 | $output .= '},'; |
551 | 723 | $output .= '"geometry": {'; |
@@ -553,15 +725,19 @@ discard block |
||
553 | 725 | $output .= '"coordinates": ['; |
554 | 726 | if ($currenttime != '') { |
555 | 727 | if (strtotime($spotter_item['date']) < $currenttime) { |
556 | - if (!isset($archivespeed)) $archivespeed = 1; |
|
728 | + if (!isset($archivespeed)) { |
|
729 | + $archivespeed = 1; |
|
730 | + } |
|
557 | 731 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
558 | 732 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
559 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
560 | - else { |
|
733 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
734 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
735 | + } else { |
|
561 | 736 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
562 | 737 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
563 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
564 | - else { |
|
738 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
739 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
740 | + } else { |
|
565 | 741 | $output .= $spotter_item['longitude'].', '; |
566 | 742 | $output .= $spotter_item['latitude']; |
567 | 743 | } |
@@ -639,7 +815,9 @@ discard block |
||
639 | 815 | } |
640 | 816 | */ |
641 | 817 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
642 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
818 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
819 | + $history = $_COOKIE['history']; |
|
820 | + } |
|
643 | 821 | |
644 | 822 | if ( |
645 | 823 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -709,8 +887,11 @@ discard block |
||
709 | 887 | $output_history .= ']}},'; |
710 | 888 | $output .= $output_history; |
711 | 889 | } |
712 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
713 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
890 | + if ($compress) { |
|
891 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
892 | + } else { |
|
893 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
894 | + } |
|
714 | 895 | } |
715 | 896 | $output_history .= '['; |
716 | 897 | $output_history .= $spotter_history['longitude'].', '; |
@@ -731,10 +912,15 @@ discard block |
||
731 | 912 | if ($d == false) { |
732 | 913 | if ($compress) { |
733 | 914 | $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",'; |
734 | - 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>",'; |
|
735 | - 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>",'; |
|
915 | + if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') { |
|
916 | + $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>",'; |
|
917 | + } elseif (isset($spotter_history_array[0]['mapmatching_engine'])) { |
|
918 | + $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
919 | + } |
|
736 | 920 | $output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
737 | - } else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
921 | + } else { |
|
922 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
923 | + } |
|
738 | 924 | $d = true; |
739 | 925 | } |
740 | 926 | $output_history .= '['; |
@@ -757,7 +943,9 @@ discard block |
||
757 | 943 | $output_historyd = '['; |
758 | 944 | $output_historyd .= $spotter_item['longitude'].', '; |
759 | 945 | $output_historyd .= $spotter_item['latitude']; |
760 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
946 | + if (isset($spotter_history['altitude'])) { |
|
947 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
948 | + } |
|
761 | 949 | $output_historyd .= '],'; |
762 | 950 | //$output_history = $output_historyd.$output_history; |
763 | 951 | $output_history = $output_history.$output_historyd; |
@@ -784,8 +972,11 @@ discard block |
||
784 | 972 | && $spotter_item['arrival_airport'] != 'NA' |
785 | 973 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
786 | 974 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
787 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
788 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
975 | + if ($compress) { |
|
976 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
977 | + } else { |
|
978 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
979 | + } |
|
789 | 980 | if (isset($spotter_item['departure_airport_latitude'])) { |
790 | 981 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
791 | 982 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -818,8 +1009,11 @@ discard block |
||
818 | 1009 | || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
819 | 1010 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
820 | 1011 | $havedata = false; |
821 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
822 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1012 | + if ($compress) { |
|
1013 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1014 | + } else { |
|
1015 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1016 | + } |
|
823 | 1017 | |
824 | 1018 | //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
825 | 1019 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -844,7 +1038,9 @@ discard block |
||
844 | 1038 | $output_dest = substr($output_dest, 0, -1); |
845 | 1039 | } |
846 | 1040 | $output_dest .= ']}},'; |
847 | - if ($havedata) $output .= $output_dest; |
|
1041 | + if ($havedata) { |
|
1042 | + $output .= $output_dest; |
|
1043 | + } |
|
848 | 1044 | unset($output_dest); |
849 | 1045 | } |
850 | 1046 | } |
@@ -852,7 +1048,9 @@ discard block |
||
852 | 1048 | $output .= ']'; |
853 | 1049 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
854 | 1050 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
855 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
1051 | + if (isset($begindate)) { |
|
1052 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
1053 | + } |
|
856 | 1054 | $output .= '"fc": "'.$j.'"'; |
857 | 1055 | } else { |
858 | 1056 | $output .= '"features": '; |