@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | if ($Schedule->checkSchedule($operator) == 0) { |
65 | 67 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 68 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
71 | + } |
|
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
69 | 73 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
70 | 74 | // Should also check if route schedule = route from DB |
@@ -73,7 +77,9 @@ discard block |
||
73 | 77 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
74 | 78 | if (trim($airport_icao) != '') { |
75 | 79 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
80 | + if ($globalDebug) { |
|
81 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
82 | + } |
|
77 | 83 | } |
78 | 84 | } |
79 | 85 | } |
@@ -82,17 +88,25 @@ discard block |
||
82 | 88 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
83 | 89 | if (trim($airport_icao) != '') { |
84 | 90 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
91 | + if ($globalDebug) { |
|
92 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | } |
88 | 96 | } |
89 | 97 | $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']); |
90 | 98 | } |
91 | - } else $scheduleexist = true; |
|
92 | - } else $scheduleexist = true; |
|
99 | + } else { |
|
100 | + $scheduleexist = true; |
|
101 | + } |
|
102 | + } else { |
|
103 | + $scheduleexist = true; |
|
104 | + } |
|
93 | 105 | // close connection, at least one way will work ? |
94 | 106 | if ($scheduleexist) { |
95 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
109 | + } |
|
96 | 110 | $sch = $Schedule->getSchedule($operator); |
97 | 111 | $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'])); |
98 | 112 | } |
@@ -114,7 +128,9 @@ discard block |
||
114 | 128 | |
115 | 129 | public function checkAll() { |
116 | 130 | global $globalDebug; |
117 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo "Update last seen flights data...\n"; |
|
133 | + } |
|
118 | 134 | foreach ($this->all_flights as $key => $flight) { |
119 | 135 | if (isset($this->all_flights[$key]['id'])) { |
120 | 136 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -127,24 +143,32 @@ discard block |
||
127 | 143 | |
128 | 144 | public function arrival($key) { |
129 | 145 | global $globalClosestMinDist, $globalDebug; |
130 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
146 | + if ($globalDebug) { |
|
147 | + echo 'Update arrival...'."\n"; |
|
148 | + } |
|
131 | 149 | $Spotter = new Spotter($this->db); |
132 | 150 | $airport_icao = ''; |
133 | 151 | $airport_time = ''; |
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
153 | + $globalClosestMinDist = 50; |
|
154 | + } |
|
135 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | 156 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
137 | 157 | if (isset($closestAirports[0])) { |
138 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 159 | $airport_icao = $closestAirports[0]['icao']; |
140 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } |
|
142 | 164 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
143 | 165 | foreach ($closestAirports as $airport) { |
144 | 166 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
145 | 167 | $airport_icao = $airport['icao']; |
146 | 168 | $airport_time = $this->all_flights[$key]['datetime']; |
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
171 | + } |
|
148 | 172 | break; |
149 | 173 | } |
150 | 174 | } |
@@ -152,14 +176,20 @@ discard block |
||
152 | 176 | $airport_icao = $closestAirports[0]['icao']; |
153 | 177 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 178 | } else { |
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
181 | + } |
|
156 | 182 | } |
157 | 183 | } else { |
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
186 | + } |
|
159 | 187 | } |
160 | 188 | |
161 | 189 | } else { |
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
190 | + if ($globalDebug) { |
|
191 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
192 | + } |
|
163 | 193 | } |
164 | 194 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
165 | 195 | } |
@@ -169,12 +199,16 @@ discard block |
||
169 | 199 | public function del() { |
170 | 200 | global $globalDebug; |
171 | 201 | // Delete old infos |
172 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Delete old values and update latest data...'."\n"; |
|
204 | + } |
|
173 | 205 | foreach ($this->all_flights as $key => $flight) { |
174 | 206 | if (isset($flight['lastupdate'])) { |
175 | 207 | if ($flight['lastupdate'] < (time()-3000)) { |
176 | 208 | if (isset($this->all_flights[$key]['id'])) { |
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
211 | + } |
|
178 | 212 | /* |
179 | 213 | $SpotterLive = new SpotterLive(); |
180 | 214 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -184,7 +218,9 @@ discard block |
||
184 | 218 | $Spotter = new Spotter($this->db); |
185 | 219 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | 220 | $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']); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
221 | + if ($globalDebug && $result != 'success') { |
|
222 | + echo '!!! ERROR : '.$result."\n"; |
|
223 | + } |
|
188 | 224 | } |
189 | 225 | // Put in archive |
190 | 226 | // $Spotter->db = null; |
@@ -198,8 +234,10 @@ discard block |
||
198 | 234 | public function add($line) { |
199 | 235 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 236 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
202 | -/* |
|
237 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
238 | + $globalCoordMinChange = '0.02'; |
|
239 | + } |
|
240 | + /* |
|
203 | 241 | $Spotter = new Spotter(); |
204 | 242 | $dbc = $Spotter->db; |
205 | 243 | $SpotterLive = new SpotterLive($dbc); |
@@ -227,11 +265,15 @@ discard block |
||
227 | 265 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | 266 | $current_date = date('Y-m-d'); |
229 | 267 | $source = $line['source_name']; |
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
268 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
269 | + $source = $line['format_source']; |
|
270 | + } |
|
231 | 271 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
232 | 272 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
233 | 273 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
274 | + } else { |
|
275 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
276 | + } |
|
235 | 277 | } |
236 | 278 | |
237 | 279 | /* |
@@ -247,8 +289,11 @@ discard block |
||
247 | 289 | //$this->db = $dbc; |
248 | 290 | |
249 | 291 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
292 | + if (!isset($line['id'])) { |
|
293 | + $id = trim($line['hex']); |
|
294 | + } else { |
|
295 | + $id = trim($line['id']); |
|
296 | + } |
|
252 | 297 | |
253 | 298 | //print_r($this->all_flights); |
254 | 299 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -263,13 +308,20 @@ discard block |
||
263 | 308 | $Spotter = new Spotter($this->db); |
264 | 309 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 310 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
311 | + if ($globalDebugTimeElapsed) { |
|
312 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + } |
|
267 | 314 | |
268 | 315 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
316 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
317 | + $aircraft_icao = 'GLID'; |
|
318 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
319 | + $aircraft_icao = 'UHEL'; |
|
320 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
321 | + $aircraft_icao = 'TOWPLANE'; |
|
322 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
323 | + $aircraft_icao = 'POWAIRC'; |
|
324 | + } |
|
273 | 325 | } |
274 | 326 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | 327 | } else if (isset($line['aircraft_name'])) { |
@@ -277,21 +329,36 @@ discard block |
||
277 | 329 | $Spotter = new Spotter($this->db); |
278 | 330 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 331 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
332 | + if ($aircraft_icao != '') { |
|
333 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
334 | + } else { |
|
335 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
339 | + } |
|
283 | 340 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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)); |
284 | 341 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
285 | 342 | if (!isset($line['id'])) { |
286 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
287 | -// 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'))); |
|
343 | + if (!isset($globalDaemon)) { |
|
344 | + $globalDaemon = TRUE; |
|
345 | + } |
|
346 | + // 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'))); |
|
288 | 347 | // 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'))); |
289 | - 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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
348 | + 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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
349 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
350 | + } |
|
290 | 351 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
352 | + } else { |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
354 | + } |
|
292 | 355 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
356 | + if ($globalDebug) { |
|
357 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
358 | + } |
|
359 | + if ($globalAllFlights !== FALSE) { |
|
360 | + $dataFound = true; |
|
361 | + } |
|
295 | 362 | } |
296 | 363 | |
297 | 364 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
@@ -299,8 +366,11 @@ discard block |
||
299 | 366 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
300 | 367 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 368 | } else { |
302 | - 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"; |
|
303 | - 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"; |
|
369 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
370 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
371 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
372 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
373 | + } |
|
304 | 374 | /* |
305 | 375 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
306 | 376 | print_r($this->all_flights[$id]); |
@@ -332,15 +402,25 @@ discard block |
||
332 | 402 | $timeelapsed = microtime(true); |
333 | 403 | $Spotter = new Spotter($this->db); |
334 | 404 | $fromsource = NULL; |
335 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
336 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
337 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
338 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
339 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
405 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
406 | + $fromsource = $globalAirlinesSource; |
|
407 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
408 | + $fromsource = 'vatsim'; |
|
409 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
410 | + $fromsource = 'ivao'; |
|
411 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
412 | + $fromsource = 'vatsim'; |
|
413 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
414 | + $fromsource = 'ivao'; |
|
415 | + } |
|
340 | 416 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
341 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
417 | + if ($globalDebug && $result != 'success') { |
|
418 | + echo '!!! ERROR : '.$result."\n"; |
|
419 | + } |
|
342 | 420 | $Spotter->db = null; |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + if ($globalDebugTimeElapsed) { |
|
422 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
423 | + } |
|
344 | 424 | } |
345 | 425 | |
346 | 426 | /* |
@@ -351,7 +431,9 @@ discard block |
||
351 | 431 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
352 | 432 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
353 | 433 | */ |
354 | - 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'])); |
|
434 | + if (!isset($this->all_flights[$id]['id'])) { |
|
435 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
436 | + } |
|
355 | 437 | |
356 | 438 | //$putinarchive = true; |
357 | 439 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -368,7 +450,9 @@ discard block |
||
368 | 450 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
369 | 451 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
370 | 452 | $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' => '')); |
371 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
453 | + if ($globalDebugTimeElapsed) { |
|
454 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
455 | + } |
|
372 | 456 | |
373 | 457 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
374 | 458 | $timeelapsed = microtime(true); |
@@ -381,7 +465,9 @@ discard block |
||
381 | 465 | $Translation->db = null; |
382 | 466 | } |
383 | 467 | $Spotter->db = null; |
384 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
468 | + if ($globalDebugTimeElapsed) { |
|
469 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
470 | + } |
|
385 | 471 | |
386 | 472 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
387 | 473 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -390,9 +476,13 @@ discard block |
||
390 | 476 | $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'])); |
391 | 477 | } |
392 | 478 | } |
393 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
479 | + if (!isset($globalFork)) { |
|
480 | + $globalFork = TRUE; |
|
481 | + } |
|
394 | 482 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
395 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
483 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
484 | + $this->get_Schedule($id,trim($line['ident'])); |
|
485 | + } |
|
396 | 486 | } |
397 | 487 | } |
398 | 488 | } |
@@ -408,16 +498,23 @@ discard block |
||
408 | 498 | // use datetime |
409 | 499 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
410 | 500 | $speed = $speed*3.6; |
411 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
412 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
501 | + if ($speed < 1000) { |
|
502 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
503 | + } |
|
504 | + if ($globalDebug) { |
|
505 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
506 | + } |
|
413 | 507 | } |
414 | 508 | } |
415 | 509 | |
416 | 510 | |
417 | 511 | |
418 | 512 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
419 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
420 | - else unset($timediff); |
|
513 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
514 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
515 | + } else { |
|
516 | + unset($timediff); |
|
517 | + } |
|
421 | 518 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
422 | 519 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
423 | 520 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -425,21 +522,31 @@ discard block |
||
425 | 522 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
426 | 523 | $this->all_flights[$id]['putinarchive'] = true; |
427 | 524 | |
428 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
525 | + if ($globalDebug) { |
|
526 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
527 | + } |
|
429 | 528 | $timeelapsed = microtime(true); |
430 | 529 | $Spotter = new Spotter($this->db); |
431 | 530 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
432 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
531 | + if (!empty($all_country)) { |
|
532 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
533 | + } |
|
433 | 534 | $Spotter->db = null; |
434 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + if ($globalDebugTimeElapsed) { |
|
536 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
537 | + } |
|
435 | 538 | $this->tmd = 0; |
436 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
539 | + if ($globalDebug) { |
|
540 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
541 | + } |
|
437 | 542 | } |
438 | 543 | } |
439 | 544 | |
440 | 545 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
441 | 546 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
442 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
547 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
548 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
549 | + } |
|
443 | 550 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
444 | 551 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
445 | 552 | $dataFound = true; |
@@ -461,9 +568,13 @@ discard block |
||
461 | 568 | */ |
462 | 569 | } |
463 | 570 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
464 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
571 | + if ($line['longitude'] > 180) { |
|
572 | + $line['longitude'] = $line['longitude'] - 360; |
|
573 | + } |
|
465 | 574 | //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) { |
466 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
575 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
576 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
577 | + } |
|
467 | 578 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
468 | 579 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
469 | 580 | $dataFound = true; |
@@ -494,7 +605,9 @@ discard block |
||
494 | 605 | } |
495 | 606 | } |
496 | 607 | if (isset($line['last_update']) && $line['last_update'] != '') { |
497 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
608 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
609 | + $dataFound = true; |
|
610 | + } |
|
498 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
499 | 612 | } |
500 | 613 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -516,40 +629,60 @@ discard block |
||
516 | 629 | // Here we force archive of flight because after ground it's a new one (or should be) |
517 | 630 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
518 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
519 | - 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'].'-'.date('YmdGi'))); |
|
520 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
521 | - 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'])); |
|
632 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
634 | + } elseif (isset($line['id'])) { |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
636 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
637 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
638 | + } |
|
639 | + } |
|
640 | + if ($line['ground'] != 1) { |
|
641 | + $line['ground'] = 0; |
|
522 | 642 | } |
523 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
524 | 643 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
525 | 644 | //$dataFound = true; |
526 | 645 | } |
527 | 646 | if (isset($line['squawk']) && $line['squawk'] != '') { |
528 | 647 | 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'])) { |
529 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
648 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
649 | + $this->all_flights[$id]['putinarchive'] = true; |
|
650 | + } |
|
530 | 651 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
531 | 652 | $highlight = ''; |
532 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
533 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
534 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
653 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
654 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
655 | + } |
|
656 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
657 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
658 | + } |
|
659 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
660 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
661 | + } |
|
535 | 662 | if ($highlight != '') { |
536 | 663 | $timeelapsed = microtime(true); |
537 | 664 | $Spotter = new Spotter($this->db); |
538 | 665 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
539 | 666 | $Spotter->db = null; |
540 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
667 | + if ($globalDebugTimeElapsed) { |
|
668 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
669 | + } |
|
541 | 670 | |
542 | 671 | //$putinarchive = true; |
543 | 672 | //$highlight = ''; |
544 | 673 | } |
545 | 674 | |
546 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
675 | + } else { |
|
676 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
677 | + } |
|
547 | 678 | //$dataFound = true; |
548 | 679 | } |
549 | 680 | |
550 | 681 | if (isset($line['altitude']) && $line['altitude'] != '') { |
551 | 682 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
552 | - 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; |
|
683 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
684 | + $this->all_flights[$id]['putinarchive'] = true; |
|
685 | + } |
|
553 | 686 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
554 | 687 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
555 | 688 | //$dataFound = true; |
@@ -561,21 +694,30 @@ discard block |
||
561 | 694 | } |
562 | 695 | |
563 | 696 | if (isset($line['heading']) && $line['heading'] != '') { |
564 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
697 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
698 | + $this->all_flights[$id]['putinarchive'] = true; |
|
699 | + } |
|
565 | 700 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
566 | 701 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
567 | 702 | //$dataFound = true; |
568 | 703 | } 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']) { |
569 | 704 | $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']); |
570 | 705 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
571 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
572 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
706 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
707 | + $this->all_flights[$id]['putinarchive'] = true; |
|
708 | + } |
|
709 | + if ($globalDebug) { |
|
710 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
711 | + } |
|
573 | 712 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
574 | 713 | // If not enough messages and ACARS set heading to 0 |
575 | 714 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
576 | 715 | } |
577 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
578 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
716 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
717 | + $dataFound = false; |
|
718 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
719 | + $dataFound = false; |
|
720 | + } |
|
579 | 721 | |
580 | 722 | // print_r($this->all_flights[$id]); |
581 | 723 | //gets the callsign from the last hour |
@@ -590,23 +732,36 @@ discard block |
||
590 | 732 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
591 | 733 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
592 | 734 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
593 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
735 | + if ($globalDebug) { |
|
736 | + echo "Check if aircraft is already in DB..."; |
|
737 | + } |
|
594 | 738 | $timeelapsed = microtime(true); |
595 | 739 | $SpotterLive = new SpotterLive($this->db); |
596 | 740 | 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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
597 | 741 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
598 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
742 | + if ($globalDebugTimeElapsed) { |
|
743 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
744 | + } |
|
599 | 745 | } elseif (isset($line['id'])) { |
600 | 746 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
601 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
747 | + if ($globalDebugTimeElapsed) { |
|
748 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
749 | + } |
|
602 | 750 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
603 | 751 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
604 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
605 | - } else $recent_ident = ''; |
|
752 | + if ($globalDebugTimeElapsed) { |
|
753 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
754 | + } |
|
755 | + } else { |
|
756 | + $recent_ident = ''; |
|
757 | + } |
|
606 | 758 | $SpotterLive->db=null; |
607 | 759 | |
608 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
609 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
760 | + if ($globalDebug && $recent_ident == '') { |
|
761 | + echo " Not in DB.\n"; |
|
762 | + } elseif ($globalDebug && $recent_ident != '') { |
|
763 | + echo " Already in DB.\n"; |
|
764 | + } |
|
610 | 765 | } else { |
611 | 766 | $recent_ident = ''; |
612 | 767 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -614,7 +769,9 @@ discard block |
||
614 | 769 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
615 | 770 | if($recent_ident == "") |
616 | 771 | { |
617 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
772 | + if ($globalDebug) { |
|
773 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
774 | + } |
|
618 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
619 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
620 | 777 | //adds the spotter data for the archive |
@@ -658,26 +815,44 @@ discard block |
||
658 | 815 | |
659 | 816 | if (!$ignoreImport) { |
660 | 817 | $highlight = ''; |
661 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
662 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
663 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
664 | - 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'))); |
|
818 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
819 | + $highlight = 'Squawk 7500 : Hijack'; |
|
820 | + } |
|
821 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
822 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
823 | + } |
|
824 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
825 | + $highlight = 'Squawk 7700 : Emergency'; |
|
826 | + } |
|
827 | + if (!isset($this->all_flights[$id]['id'])) { |
|
828 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
829 | + } |
|
665 | 830 | $timeelapsed = microtime(true); |
666 | 831 | $Spotter = new Spotter($this->db); |
667 | 832 | $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]['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']); |
668 | 833 | $Spotter->db = null; |
669 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
670 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
834 | + if ($globalDebug && isset($result)) { |
|
835 | + echo $result."\n"; |
|
836 | + } |
|
837 | + if ($globalDebugTimeElapsed) { |
|
838 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
839 | + } |
|
671 | 840 | |
672 | 841 | // Add source stat in DB |
673 | 842 | $Stats = new Stats($this->db); |
674 | 843 | if (!empty($this->stats)) { |
675 | - if ($globalDebug) echo 'Add source stats : '; |
|
844 | + if ($globalDebug) { |
|
845 | + echo 'Add source stats : '; |
|
846 | + } |
|
676 | 847 | foreach($this->stats as $date => $data) { |
677 | 848 | foreach($data as $source => $sourced) { |
678 | 849 | //print_r($sourced); |
679 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
680 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
850 | + if (isset($sourced['polar'])) { |
|
851 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
852 | + } |
|
853 | + if (isset($sourced['hist'])) { |
|
854 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
855 | + } |
|
681 | 856 | if (isset($sourced['msg'])) { |
682 | 857 | if (time() - $sourced['msg']['date'] > 10) { |
683 | 858 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -690,13 +865,17 @@ discard block |
||
690 | 865 | unset($this->stats[$date]); |
691 | 866 | } |
692 | 867 | } |
693 | - if ($globalDebug) echo 'Done'."\n"; |
|
868 | + if ($globalDebug) { |
|
869 | + echo 'Done'."\n"; |
|
870 | + } |
|
694 | 871 | |
695 | 872 | } |
696 | 873 | $Stats->db = null; |
697 | 874 | |
698 | 875 | $this->del(); |
699 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
876 | + } elseif ($globalDebug) { |
|
877 | + echo 'Ignore data'."\n"; |
|
878 | + } |
|
700 | 879 | //$ignoreImport = false; |
701 | 880 | $this->all_flights[$id]['addedSpotter'] = 1; |
702 | 881 | //print_r($this->all_flights[$id]); |
@@ -713,12 +892,16 @@ discard block |
||
713 | 892 | */ |
714 | 893 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
715 | 894 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
716 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
895 | + if ($globalDebug) { |
|
896 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
897 | + } |
|
717 | 898 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
718 | 899 | $SpotterLive = new SpotterLive($this->db); |
719 | 900 | $SpotterLive->deleteLiveSpotterData(); |
720 | 901 | $SpotterLive->db=null; |
721 | - if ($globalDebug) echo " Done\n"; |
|
902 | + if ($globalDebug) { |
|
903 | + echo " Done\n"; |
|
904 | + } |
|
722 | 905 | $this->last_delete = time(); |
723 | 906 | } |
724 | 907 | } else { |
@@ -741,11 +924,17 @@ discard block |
||
741 | 924 | //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"; |
742 | 925 | if ($globalDebug) { |
743 | 926 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
744 | - 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"; |
|
745 | - 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"; |
|
927 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
928 | + 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"; |
|
929 | + } else { |
|
930 | + 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"; |
|
931 | + } |
|
746 | 932 | } else { |
747 | - 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"; |
|
748 | - 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"; |
|
933 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
934 | + 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 { |
|
936 | + 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"; |
|
937 | + } |
|
749 | 938 | } |
750 | 939 | } |
751 | 940 | $ignoreImport = false; |
@@ -791,20 +980,26 @@ discard block |
||
791 | 980 | |
792 | 981 | if (!$ignoreImport) { |
793 | 982 | 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'])) { |
794 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
983 | + if ($globalDebug) { |
|
984 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
985 | + } |
|
795 | 986 | $timeelapsed = microtime(true); |
796 | 987 | $SpotterLive = new SpotterLive($this->db); |
797 | 988 | $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]['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']); |
798 | 989 | $SpotterLive->db = null; |
799 | 990 | $this->all_flights[$id]['putinarchive'] = false; |
800 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
991 | + if ($globalDebugTimeElapsed) { |
|
992 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
993 | + } |
|
801 | 994 | |
802 | 995 | // Put statistics in $this->stats variable |
803 | 996 | //if ($line['format_source'] != 'aprs') { |
804 | 997 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
805 | 998 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
806 | 999 | $source = $this->all_flights[$id]['source_name']; |
807 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1000 | + if ($source == '') { |
|
1001 | + $source = $this->all_flights[$id]['format_source']; |
|
1002 | + } |
|
808 | 1003 | if (!isset($this->source_location[$source])) { |
809 | 1004 | $Location = new Source(); |
810 | 1005 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -825,7 +1020,9 @@ discard block |
||
825 | 1020 | $stats_heading = round($stats_heading/22.5); |
826 | 1021 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
827 | 1022 | $current_date = date('Y-m-d'); |
828 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1023 | + if ($stats_heading == 16) { |
|
1024 | + $stats_heading = 0; |
|
1025 | + } |
|
829 | 1026 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
830 | 1027 | for ($i=0;$i<=15;$i++) { |
831 | 1028 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -843,7 +1040,9 @@ discard block |
||
843 | 1040 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
844 | 1041 | end($this->stats[$current_date][$source]['hist']); |
845 | 1042 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
846 | - } else $mini = 0; |
|
1043 | + } else { |
|
1044 | + $mini = 0; |
|
1045 | + } |
|
847 | 1046 | for ($i=$mini;$i<=$distance;$i+=10) { |
848 | 1047 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
849 | 1048 | } |
@@ -854,20 +1053,30 @@ discard block |
||
854 | 1053 | } |
855 | 1054 | |
856 | 1055 | $this->all_flights[$id]['lastupdate'] = time(); |
857 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1056 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1057 | + $send = true; |
|
1058 | + } |
|
858 | 1059 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
859 | - if ($globalDebug) echo $result."\n"; |
|
860 | - } 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"; |
|
1060 | + if ($globalDebug) { |
|
1061 | + echo $result."\n"; |
|
1062 | + } |
|
1063 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1064 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1065 | + } |
|
861 | 1066 | //$this->del(); |
862 | 1067 | |
863 | 1068 | |
864 | 1069 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
865 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1070 | + if ($globalDebug) { |
|
1071 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1072 | + } |
|
866 | 1073 | $SpotterLive = new SpotterLive($this->db); |
867 | 1074 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
868 | 1075 | $SpotterLive->db = null; |
869 | 1076 | //SpotterLive->deleteLiveSpotterData(); |
870 | - if ($globalDebug) echo " Done\n"; |
|
1077 | + if ($globalDebug) { |
|
1078 | + echo " Done\n"; |
|
1079 | + } |
|
871 | 1080 | $this->last_delete_hourly = time(); |
872 | 1081 | } |
873 | 1082 | |
@@ -875,7 +1084,9 @@ discard block |
||
875 | 1084 | //$ignoreImport = false; |
876 | 1085 | } |
877 | 1086 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
878 | - if ($send) return $this->all_flights[$id]; |
|
1087 | + if ($send) { |
|
1088 | + return $this->all_flights[$id]; |
|
1089 | + } |
|
879 | 1090 | } |
880 | 1091 | } |
881 | 1092 | } |