@@ -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); |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | if ($Schedule->checkSchedule($operator) == 0) { |
64 | 66 | $schedule = $Schedule->fetchSchedule($operator); |
65 | 67 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
66 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | + if ($globalDebug) { |
|
69 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
70 | + } |
|
67 | 71 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
69 | 73 | // Should also check if route schedule = route from DB |
@@ -72,7 +76,9 @@ discard block |
||
72 | 76 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
73 | 77 | if ($airport_icao != '') { |
74 | 78 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
75 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
81 | + } |
|
76 | 82 | } |
77 | 83 | } |
78 | 84 | } |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
82 | 88 | if ($airport_icao != '') { |
83 | 89 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
84 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
85 | 93 | } |
86 | 94 | } |
87 | 95 | } |
@@ -109,7 +117,9 @@ discard block |
||
109 | 117 | |
110 | 118 | public function checkAll() { |
111 | 119 | global $globalDebug; |
112 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo "Update last seen flights data...\n"; |
|
122 | + } |
|
113 | 123 | foreach ($this->all_flights as $key => $flight) { |
114 | 124 | if (isset($this->all_flights[$key]['id'])) { |
115 | 125 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -122,24 +132,32 @@ discard block |
||
122 | 132 | |
123 | 133 | public function arrival($key) { |
124 | 134 | global $globalClosestMinDist, $globalDebug; |
125 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
135 | + if ($globalDebug) { |
|
136 | + echo 'Update arrival...'."\n"; |
|
137 | + } |
|
126 | 138 | $Spotter = new Spotter($this->db); |
127 | 139 | $airport_icao = ''; |
128 | 140 | $airport_time = ''; |
129 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
141 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
142 | + $globalClosestMinDist = 50; |
|
143 | + } |
|
130 | 144 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
131 | 145 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
132 | 146 | if (isset($closestAirports[0])) { |
133 | 147 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
134 | 148 | $airport_icao = $closestAirports[0]['icao']; |
135 | 149 | $airport_time = $this->all_flights[$key]['datetime']; |
136 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
152 | + } |
|
137 | 153 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
138 | 154 | foreach ($closestAirports as $airport) { |
139 | 155 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
140 | 156 | $airport_icao = $airport['icao']; |
141 | 157 | $airport_time = $this->all_flights[$key]['datetime']; |
142 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | + } |
|
143 | 161 | break; |
144 | 162 | } |
145 | 163 | } |
@@ -147,14 +165,20 @@ discard block |
||
147 | 165 | $airport_icao = $closestAirports[0]['icao']; |
148 | 166 | $airport_time = $this->all_flights[$key]['datetime']; |
149 | 167 | } else { |
150 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | + if ($globalDebug) { |
|
169 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
170 | + } |
|
151 | 171 | } |
152 | 172 | } else { |
153 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
175 | + } |
|
154 | 176 | } |
155 | 177 | |
156 | 178 | } else { |
157 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
181 | + } |
|
158 | 182 | } |
159 | 183 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
160 | 184 | } |
@@ -164,12 +188,16 @@ discard block |
||
164 | 188 | public function del() { |
165 | 189 | global $globalDebug; |
166 | 190 | // Delete old infos |
167 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
191 | + if ($globalDebug) { |
|
192 | + echo 'Delete old values and update latest data...'."\n"; |
|
193 | + } |
|
168 | 194 | foreach ($this->all_flights as $key => $flight) { |
169 | 195 | if (isset($flight['lastupdate'])) { |
170 | 196 | if ($flight['lastupdate'] < (time()-3000)) { |
171 | 197 | if (isset($this->all_flights[$key]['id'])) { |
172 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
200 | + } |
|
173 | 201 | /* |
174 | 202 | $SpotterLive = new SpotterLive(); |
175 | 203 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -179,7 +207,9 @@ discard block |
||
179 | 207 | $Spotter = new Spotter($this->db); |
180 | 208 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
181 | 209 | $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']); |
182 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
210 | + if ($globalDebug && $result != 'success') { |
|
211 | + echo '!!! ERROR : '.$result."\n"; |
|
212 | + } |
|
183 | 213 | } |
184 | 214 | // Put in archive |
185 | 215 | // $Spotter->db = null; |
@@ -193,8 +223,10 @@ discard block |
||
193 | 223 | public function add($line) { |
194 | 224 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
195 | 225 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
196 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
197 | -/* |
|
226 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
227 | + $globalCoordMinChange = '0.02'; |
|
228 | + } |
|
229 | + /* |
|
198 | 230 | $Spotter = new Spotter(); |
199 | 231 | $dbc = $Spotter->db; |
200 | 232 | $SpotterLive = new SpotterLive($dbc); |
@@ -222,11 +254,15 @@ discard block |
||
222 | 254 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
223 | 255 | $current_date = date('Y-m-d'); |
224 | 256 | $source = $line['source_name']; |
225 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
257 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
258 | + $source = $line['format_source']; |
|
259 | + } |
|
226 | 260 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
227 | 261 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
228 | 262 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
229 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
263 | + } else { |
|
264 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
265 | + } |
|
230 | 266 | } |
231 | 267 | |
232 | 268 | /* |
@@ -242,8 +278,11 @@ discard block |
||
242 | 278 | //$this->db = $dbc; |
243 | 279 | |
244 | 280 | $hex = trim($line['hex']); |
245 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
246 | - else $id = trim($line['id']); |
|
281 | + if (!isset($line['id'])) { |
|
282 | + $id = trim($line['hex']); |
|
283 | + } else { |
|
284 | + $id = trim($line['id']); |
|
285 | + } |
|
247 | 286 | |
248 | 287 | //print_r($this->all_flights); |
249 | 288 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -258,13 +297,20 @@ discard block |
||
258 | 297 | $Spotter = new Spotter($this->db); |
259 | 298 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
260 | 299 | $Spotter->db = null; |
261 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + if ($globalDebugTimeElapsed) { |
|
301 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | + } |
|
262 | 303 | |
263 | 304 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
264 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
265 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
266 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
267 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
305 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
306 | + $aircraft_icao = 'GLID'; |
|
307 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
308 | + $aircraft_icao = 'UHEL'; |
|
309 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
310 | + $aircraft_icao = 'TOWPLANE'; |
|
311 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
312 | + $aircraft_icao = 'POWAIRC'; |
|
313 | + } |
|
268 | 314 | } |
269 | 315 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
270 | 316 | } else if (isset($line['aircraft_name'])) { |
@@ -272,29 +318,47 @@ discard block |
||
272 | 318 | $Spotter = new Spotter($this->db); |
273 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
274 | 320 | $Spotter->db = null; |
275 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
276 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
277 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
321 | + if ($aircraft_icao != '') { |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
323 | + } else { |
|
324 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
325 | + } |
|
326 | + } else { |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
328 | + } |
|
278 | 329 | $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)); |
279 | 330 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
280 | 331 | if (!isset($line['id'])) { |
281 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
282 | -// 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'))); |
|
332 | + if (!isset($globalDaemon)) { |
|
333 | + $globalDaemon = TRUE; |
|
334 | + } |
|
335 | + // 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'))); |
|
283 | 336 | // 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'))); |
284 | - 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'))); |
|
337 | + 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')) { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
339 | + } |
|
285 | 340 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
286 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
341 | + } else { |
|
342 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
343 | + } |
|
287 | 344 | |
288 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
289 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
345 | + if ($globalDebug) { |
|
346 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
347 | + } |
|
348 | + if ($globalAllFlights !== FALSE) { |
|
349 | + $dataFound = true; |
|
350 | + } |
|
290 | 351 | } |
291 | 352 | |
292 | 353 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
293 | 354 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
294 | 355 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
295 | 356 | } else { |
296 | - 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"; |
|
297 | - 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"; |
|
357 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
358 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
359 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
360 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
361 | + } |
|
298 | 362 | /* |
299 | 363 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
300 | 364 | print_r($this->all_flights[$id]); |
@@ -302,7 +366,9 @@ discard block |
||
302 | 366 | */ |
303 | 367 | return ''; |
304 | 368 | } |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
369 | + } else { |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | + } |
|
306 | 372 | |
307 | 373 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
308 | 374 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -323,15 +389,25 @@ discard block |
||
323 | 389 | $timeelapsed = microtime(true); |
324 | 390 | $Spotter = new Spotter($this->db); |
325 | 391 | $fromsource = NULL; |
326 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
327 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
328 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
329 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
330 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
392 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
393 | + $fromsource = $globalAirlinesSource; |
|
394 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
395 | + $fromsource = 'vatsim'; |
|
396 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
397 | + $fromsource = 'ivao'; |
|
398 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
399 | + $fromsource = 'vatsim'; |
|
400 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
401 | + $fromsource = 'ivao'; |
|
402 | + } |
|
331 | 403 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
332 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
404 | + if ($globalDebug && $result != 'success') { |
|
405 | + echo '!!! ERROR : '.$result."\n"; |
|
406 | + } |
|
333 | 407 | $Spotter->db = null; |
334 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
408 | + if ($globalDebugTimeElapsed) { |
|
409 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
410 | + } |
|
335 | 411 | } |
336 | 412 | |
337 | 413 | /* |
@@ -342,7 +418,9 @@ discard block |
||
342 | 418 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
343 | 419 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
344 | 420 | */ |
345 | - 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'])); |
|
421 | + if (!isset($this->all_flights[$id]['id'])) { |
|
422 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
423 | + } |
|
346 | 424 | |
347 | 425 | //$putinarchive = true; |
348 | 426 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -359,7 +437,9 @@ discard block |
||
359 | 437 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
360 | 438 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
361 | 439 | $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' => '')); |
362 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
440 | + if ($globalDebugTimeElapsed) { |
|
441 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
442 | + } |
|
363 | 443 | |
364 | 444 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
365 | 445 | $timeelapsed = microtime(true); |
@@ -372,7 +452,9 @@ discard block |
||
372 | 452 | $Translation->db = null; |
373 | 453 | } |
374 | 454 | $Spotter->db = null; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
455 | + if ($globalDebugTimeElapsed) { |
|
456 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
457 | + } |
|
376 | 458 | |
377 | 459 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
378 | 460 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -381,9 +463,13 @@ discard block |
||
381 | 463 | $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'])); |
382 | 464 | } |
383 | 465 | } |
384 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
466 | + if (!isset($globalFork)) { |
|
467 | + $globalFork = TRUE; |
|
468 | + } |
|
385 | 469 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
386 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
470 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
471 | + $this->get_Schedule($id,trim($line['ident'])); |
|
472 | + } |
|
387 | 473 | } |
388 | 474 | } |
389 | 475 | } |
@@ -399,16 +485,23 @@ discard block |
||
399 | 485 | // use datetime |
400 | 486 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
401 | 487 | $speed = $speed*3.6; |
402 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
403 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
488 | + if ($speed < 1000) { |
|
489 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
490 | + } |
|
491 | + if ($globalDebug) { |
|
492 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
493 | + } |
|
404 | 494 | } |
405 | 495 | } |
406 | 496 | |
407 | 497 | |
408 | 498 | |
409 | 499 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
410 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
411 | - else unset($timediff); |
|
500 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
501 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + } else { |
|
503 | + unset($timediff); |
|
504 | + } |
|
412 | 505 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && 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')))) { |
413 | 506 | 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'])) { |
414 | 507 | 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'])) { |
@@ -416,21 +509,31 @@ discard block |
||
416 | 509 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
417 | 510 | $this->all_flights[$id]['putinarchive'] = true; |
418 | 511 | |
419 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
512 | + if ($globalDebug) { |
|
513 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
514 | + } |
|
420 | 515 | $timeelapsed = microtime(true); |
421 | 516 | $Spotter = new Spotter($this->db); |
422 | 517 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
423 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
518 | + if (!empty($all_country)) { |
|
519 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
520 | + } |
|
424 | 521 | $Spotter->db = null; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
522 | + if ($globalDebugTimeElapsed) { |
|
523 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + } |
|
426 | 525 | $this->tmd = 0; |
427 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
526 | + if ($globalDebug) { |
|
527 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
528 | + } |
|
428 | 529 | } |
429 | 530 | } |
430 | 531 | |
431 | 532 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
432 | 533 | //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) { |
433 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
534 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
535 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
536 | + } |
|
434 | 537 | 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') { |
435 | 538 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
436 | 539 | $dataFound = true; |
@@ -452,9 +555,13 @@ discard block |
||
452 | 555 | */ |
453 | 556 | } |
454 | 557 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
455 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
558 | + if ($line['longitude'] > 180) { |
|
559 | + $line['longitude'] = $line['longitude'] - 360; |
|
560 | + } |
|
456 | 561 | //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) { |
457 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
562 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
563 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
564 | + } |
|
458 | 565 | 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') { |
459 | 566 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
460 | 567 | $dataFound = true; |
@@ -485,7 +592,9 @@ discard block |
||
485 | 592 | } |
486 | 593 | } |
487 | 594 | if (isset($line['last_update']) && $line['last_update'] != '') { |
488 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
595 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
596 | + $dataFound = true; |
|
597 | + } |
|
489 | 598 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
490 | 599 | } |
491 | 600 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -507,11 +616,17 @@ discard block |
||
507 | 616 | // Here we force archive of flight because after ground it's a new one (or should be) |
508 | 617 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
509 | 618 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
510 | - 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'))); |
|
511 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
512 | - 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'])); |
|
619 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
621 | + } elseif (isset($line['id'])) { |
|
622 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
623 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
624 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
625 | + } |
|
626 | + } |
|
627 | + if ($line['ground'] != 1) { |
|
628 | + $line['ground'] = 0; |
|
513 | 629 | } |
514 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
515 | 630 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
516 | 631 | //$dataFound = true; |
517 | 632 | } |
@@ -519,28 +634,40 @@ discard block |
||
519 | 634 | 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'])) { |
520 | 635 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
521 | 636 | $highlight = ''; |
522 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
523 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
524 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
637 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
638 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
639 | + } |
|
640 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
641 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
642 | + } |
|
643 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
644 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
645 | + } |
|
525 | 646 | if ($highlight != '') { |
526 | 647 | $timeelapsed = microtime(true); |
527 | 648 | $Spotter = new Spotter($this->db); |
528 | 649 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
529 | 650 | $Spotter->db = null; |
530 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
651 | + if ($globalDebugTimeElapsed) { |
|
652 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
653 | + } |
|
531 | 654 | |
532 | 655 | $this->all_flights[$id]['putinarchive'] = true; |
533 | 656 | //$putinarchive = true; |
534 | 657 | //$highlight = ''; |
535 | 658 | } |
536 | 659 | |
537 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
660 | + } else { |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
662 | + } |
|
538 | 663 | //$dataFound = true; |
539 | 664 | } |
540 | 665 | |
541 | 666 | if (isset($line['altitude']) && $line['altitude'] != '') { |
542 | 667 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
543 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
669 | + $this->all_flights[$id]['putinarchive'] = true; |
|
670 | + } |
|
544 | 671 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
545 | 672 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
546 | 673 | //$dataFound = true; |
@@ -552,21 +679,30 @@ discard block |
||
552 | 679 | } |
553 | 680 | |
554 | 681 | if (isset($line['heading']) && $line['heading'] != '') { |
555 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
682 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
683 | + $this->all_flights[$id]['putinarchive'] = true; |
|
684 | + } |
|
556 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
557 | 686 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
558 | 687 | //$dataFound = true; |
559 | 688 | } 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']) { |
560 | 689 | $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']); |
561 | 690 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
562 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
563 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
691 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
692 | + $this->all_flights[$id]['putinarchive'] = true; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
696 | + } |
|
564 | 697 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
565 | 698 | // If not enough messages and ACARS set heading to 0 |
566 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
567 | 700 | } |
568 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
569 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
701 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
702 | + $dataFound = false; |
|
703 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
704 | + $dataFound = false; |
|
705 | + } |
|
570 | 706 | |
571 | 707 | // print_r($this->all_flights[$id]); |
572 | 708 | //gets the callsign from the last hour |
@@ -581,23 +717,36 @@ discard block |
||
581 | 717 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
582 | 718 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
583 | 719 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
584 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
720 | + if ($globalDebug) { |
|
721 | + echo "Check if aircraft is already in DB..."; |
|
722 | + } |
|
585 | 723 | $timeelapsed = microtime(true); |
586 | 724 | $SpotterLive = new SpotterLive($this->db); |
587 | 725 | 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')) { |
588 | 726 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
589 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
727 | + if ($globalDebugTimeElapsed) { |
|
728 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
729 | + } |
|
590 | 730 | } elseif (isset($line['id'])) { |
591 | 731 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
592 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
732 | + if ($globalDebugTimeElapsed) { |
|
733 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
734 | + } |
|
593 | 735 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
594 | 736 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
595 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | - } else $recent_ident = ''; |
|
737 | + if ($globalDebugTimeElapsed) { |
|
738 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
739 | + } |
|
740 | + } else { |
|
741 | + $recent_ident = ''; |
|
742 | + } |
|
597 | 743 | $SpotterLive->db=null; |
598 | 744 | |
599 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
600 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
745 | + if ($globalDebug && $recent_ident == '') { |
|
746 | + echo " Not in DB.\n"; |
|
747 | + } elseif ($globalDebug && $recent_ident != '') { |
|
748 | + echo " Already in DB.\n"; |
|
749 | + } |
|
601 | 750 | } else { |
602 | 751 | $recent_ident = ''; |
603 | 752 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -605,7 +754,9 @@ discard block |
||
605 | 754 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
606 | 755 | if($recent_ident == "") |
607 | 756 | { |
608 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
757 | + if ($globalDebug) { |
|
758 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
759 | + } |
|
609 | 760 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
610 | 761 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
611 | 762 | //adds the spotter data for the archive |
@@ -649,26 +800,44 @@ discard block |
||
649 | 800 | |
650 | 801 | if (!$ignoreImport) { |
651 | 802 | $highlight = ''; |
652 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
653 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
654 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
655 | - 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'))); |
|
803 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
804 | + $highlight = 'Squawk 7500 : Hijack'; |
|
805 | + } |
|
806 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
807 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
808 | + } |
|
809 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
810 | + $highlight = 'Squawk 7700 : Emergency'; |
|
811 | + } |
|
812 | + if (!isset($this->all_flights[$id]['id'])) { |
|
813 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
814 | + } |
|
656 | 815 | $timeelapsed = microtime(true); |
657 | 816 | $Spotter = new Spotter($this->db); |
658 | 817 | $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']); |
659 | 818 | $Spotter->db = null; |
660 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
661 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
819 | + if ($globalDebug && isset($result)) { |
|
820 | + echo $result."\n"; |
|
821 | + } |
|
822 | + if ($globalDebugTimeElapsed) { |
|
823 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
824 | + } |
|
662 | 825 | |
663 | 826 | // Add source stat in DB |
664 | 827 | $Stats = new Stats($this->db); |
665 | 828 | if (!empty($this->stats)) { |
666 | - if ($globalDebug) echo 'Add source stats : '; |
|
829 | + if ($globalDebug) { |
|
830 | + echo 'Add source stats : '; |
|
831 | + } |
|
667 | 832 | foreach($this->stats as $date => $data) { |
668 | 833 | foreach($data as $source => $sourced) { |
669 | 834 | //print_r($sourced); |
670 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
671 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
835 | + if (isset($sourced['polar'])) { |
|
836 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
837 | + } |
|
838 | + if (isset($sourced['hist'])) { |
|
839 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
840 | + } |
|
672 | 841 | if (isset($sourced['msg'])) { |
673 | 842 | if (time() - $sourced['msg']['date'] > 10) { |
674 | 843 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -681,13 +850,17 @@ discard block |
||
681 | 850 | unset($this->stats[$date]); |
682 | 851 | } |
683 | 852 | } |
684 | - if ($globalDebug) echo 'Done'."\n"; |
|
853 | + if ($globalDebug) { |
|
854 | + echo 'Done'."\n"; |
|
855 | + } |
|
685 | 856 | |
686 | 857 | } |
687 | 858 | $Stats->db = null; |
688 | 859 | |
689 | 860 | $this->del(); |
690 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
861 | + } elseif ($globalDebug) { |
|
862 | + echo 'Ignore data'."\n"; |
|
863 | + } |
|
691 | 864 | //$ignoreImport = false; |
692 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
693 | 866 | //print_r($this->all_flights[$id]); |
@@ -704,12 +877,16 @@ discard block |
||
704 | 877 | */ |
705 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
706 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
707 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
880 | + if ($globalDebug) { |
|
881 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | + } |
|
708 | 883 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
709 | 884 | $SpotterLive = new SpotterLive($this->db); |
710 | 885 | $SpotterLive->deleteLiveSpotterData(); |
711 | 886 | $SpotterLive->db=null; |
712 | - if ($globalDebug) echo " Done\n"; |
|
887 | + if ($globalDebug) { |
|
888 | + echo " Done\n"; |
|
889 | + } |
|
713 | 890 | $this->last_delete = time(); |
714 | 891 | } |
715 | 892 | } else { |
@@ -732,11 +909,17 @@ discard block |
||
732 | 909 | //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"; |
733 | 910 | if ($globalDebug) { |
734 | 911 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
735 | - 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"; |
|
736 | - 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"; |
|
912 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
913 | + 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"; |
|
914 | + } else { |
|
915 | + 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"; |
|
916 | + } |
|
737 | 917 | } else { |
738 | - 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"; |
|
739 | - 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"; |
|
918 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
919 | + 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"; |
|
920 | + } else { |
|
921 | + 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"; |
|
922 | + } |
|
740 | 923 | } |
741 | 924 | } |
742 | 925 | $ignoreImport = false; |
@@ -782,19 +965,25 @@ discard block |
||
782 | 965 | |
783 | 966 | if (!$ignoreImport) { |
784 | 967 | 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'])) { |
785 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
968 | + if ($globalDebug) { |
|
969 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
970 | + } |
|
786 | 971 | $timeelapsed = microtime(true); |
787 | 972 | $SpotterLive = new SpotterLive($this->db); |
788 | 973 | $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']); |
789 | 974 | $SpotterLive->db = null; |
790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
975 | + if ($globalDebugTimeElapsed) { |
|
976 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
977 | + } |
|
791 | 978 | |
792 | 979 | // Put statistics in $this->stats variable |
793 | 980 | //if ($line['format_source'] != 'aprs') { |
794 | 981 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
795 | 982 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
796 | 983 | $source = $this->all_flights[$id]['source_name']; |
797 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
984 | + if ($source == '') { |
|
985 | + $source = $this->all_flights[$id]['format_source']; |
|
986 | + } |
|
798 | 987 | if (!isset($this->source_location[$source])) { |
799 | 988 | $Location = new Source(); |
800 | 989 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -815,7 +1004,9 @@ discard block |
||
815 | 1004 | $stats_heading = round($stats_heading/22.5); |
816 | 1005 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
817 | 1006 | $current_date = date('Y-m-d'); |
818 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1007 | + if ($stats_heading == 16) { |
|
1008 | + $stats_heading = 0; |
|
1009 | + } |
|
819 | 1010 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
820 | 1011 | for ($i=0;$i<=15;$i++) { |
821 | 1012 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -833,7 +1024,9 @@ discard block |
||
833 | 1024 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
834 | 1025 | end($this->stats[$current_date][$source]['hist']); |
835 | 1026 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
836 | - } else $mini = 0; |
|
1027 | + } else { |
|
1028 | + $mini = 0; |
|
1029 | + } |
|
837 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
838 | 1031 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
839 | 1032 | } |
@@ -844,20 +1037,30 @@ discard block |
||
844 | 1037 | } |
845 | 1038 | |
846 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
847 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1040 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1041 | + $send = true; |
|
1042 | + } |
|
848 | 1043 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
849 | - if ($globalDebug) echo $result."\n"; |
|
850 | - } 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"; |
|
1044 | + if ($globalDebug) { |
|
1045 | + echo $result."\n"; |
|
1046 | + } |
|
1047 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1048 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1049 | + } |
|
851 | 1050 | //$this->del(); |
852 | 1051 | |
853 | 1052 | |
854 | 1053 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
855 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1054 | + if ($globalDebug) { |
|
1055 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1056 | + } |
|
856 | 1057 | $SpotterLive = new SpotterLive($this->db); |
857 | 1058 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
858 | 1059 | $SpotterLive->db = null; |
859 | 1060 | //SpotterLive->deleteLiveSpotterData(); |
860 | - if ($globalDebug) echo " Done\n"; |
|
1061 | + if ($globalDebug) { |
|
1062 | + echo " Done\n"; |
|
1063 | + } |
|
861 | 1064 | $this->last_delete_hourly = time(); |
862 | 1065 | } |
863 | 1066 | |
@@ -865,7 +1068,9 @@ discard block |
||
865 | 1068 | //$ignoreImport = false; |
866 | 1069 | } |
867 | 1070 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
868 | - if ($send) return $this->all_flights[$id]; |
|
1071 | + if ($send) { |
|
1072 | + return $this->all_flights[$id]; |
|
1073 | + } |
|
869 | 1074 | } |
870 | 1075 | } |
871 | 1076 | } |