@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | $currentdate = date('Y-m-d'); |
33 | 33 | $sourcestat = $Stats->getStatsSource($currentdate); |
34 | 34 | if (!empty($sourcestat)) { |
35 | - foreach($sourcestat as $srcst) { |
|
35 | + foreach ($sourcestat as $srcst) { |
|
36 | 36 | $type = $srcst['stats_type']; |
37 | 37 | if ($type == 'polar' || $type == 'hist') { |
38 | 38 | $source = $srcst['source_name']; |
39 | 39 | $data = $srcst['source_data']; |
40 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
40 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | - public function get_Schedule($id,$ident) { |
|
51 | + public function get_Schedule($id, $ident) { |
|
52 | 52 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
53 | 53 | // Get schedule here, so it's done only one time |
54 | 54 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $schedule = $Schedule->fetchSchedule($operator); |
74 | 74 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
75 | 75 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
76 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
76 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | 78 | // Should also check if route schedule = route from DB |
79 | 79 | if ($schedule['DepartureAirportIATA'] != '') { |
80 | 80 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
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']); |
|
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']); |
|
98 | 98 | } |
99 | 99 | } else $scheduleexist = true; |
100 | 100 | } else $scheduleexist = true; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($scheduleexist) { |
103 | 103 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
104 | 104 | $sch = $Schedule->getSchedule($operator); |
105 | - $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'])); |
|
105 | + $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'])); |
|
106 | 106 | } |
107 | 107 | $Spotter->db = null; |
108 | 108 | $Schedule->db = null; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
130 | 130 | $Spotter = new Spotter($this->db); |
131 | 131 | $real_arrival = $this->arrival($key); |
132 | - $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']); |
|
132 | + $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']); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $airport_time = ''; |
144 | 144 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
145 | 145 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
146 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
146 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
147 | 147 | if (isset($closestAirports[0])) { |
148 | 148 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
149 | 149 | $airport_icao = $closestAirports[0]['icao']; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | break; |
159 | 159 | } |
160 | 160 | } |
161 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
161 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
162 | 162 | $airport_icao = $closestAirports[0]['icao']; |
163 | 163 | $airport_time = $this->all_flights[$key]['datetime']; |
164 | 164 | } else { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } else { |
172 | 172 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
173 | 173 | } |
174 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
174 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
183 | 183 | foreach ($this->all_flights as $key => $flight) { |
184 | 184 | if (isset($flight['lastupdate'])) { |
185 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
185 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
186 | 186 | if (isset($this->all_flights[$key]['id'])) { |
187 | 187 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
188 | 188 | /* |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $real_arrival = $this->arrival($key); |
195 | 195 | $Spotter = new Spotter($this->db); |
196 | 196 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
197 | - $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']); |
|
197 | + $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']); |
|
198 | 198 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
199 | 199 | } |
200 | 200 | // Put in archive |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $send = false; |
232 | 232 | |
233 | 233 | // SBS format is CSV format |
234 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
234 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
235 | 235 | //print_r($line); |
236 | 236 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
237 | 237 | |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | |
265 | 265 | if (!isset($this->all_flights[$id])) { |
266 | 266 | $this->all_flights[$id] = array(); |
267 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
268 | - $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,'source_type' => '')); |
|
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
267 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
268 | + $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, 'source_type' => '')); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
270 | 270 | if (!isset($line['id'])) { |
271 | 271 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
272 | 272 | // 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'))); |
273 | 273 | // 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'))); |
274 | - 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' => $id.'-'.date('YmdHi'))); |
|
274 | + 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' => $id.'-'.date('YmdHi'))); |
|
275 | 275 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
276 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
276 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
277 | 277 | if ($globalAllFlights !== FALSE) $dataFound = true; |
278 | 278 | } |
279 | 279 | if (isset($line['source_type']) && $line['source_type'] != '') { |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | //print_r($this->all_flights); |
284 | 284 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
286 | 286 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
287 | 287 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
288 | 288 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
292 | 292 | $Spotter = new Spotter($this->db); |
293 | 293 | if (isset($this->all_flights[$id]['source_type'])) { |
294 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
294 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
295 | 295 | } else { |
296 | 296 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
297 | 297 | } |
298 | 298 | $Spotter->db = null; |
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
299 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
300 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | if ($globalAllFlights !== FALSE) $dataFound = true; |
304 | 304 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
305 | 305 | } |
306 | 306 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
307 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
307 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
308 | 308 | } |
309 | 309 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $Spotter = new Spotter($this->db); |
313 | 313 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
314 | 314 | $Spotter->db = null; |
315 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
315 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -320,15 +320,15 @@ discard block |
||
320 | 320 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
321 | 321 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
322 | 322 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
323 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
323 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
324 | 324 | } |
325 | 325 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
327 | 327 | } |
328 | 328 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
329 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
329 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
330 | 330 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
331 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
332 | 332 | } else { |
333 | 333 | 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"; |
334 | 334 | 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"; |
@@ -341,24 +341,24 @@ discard block |
||
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | date_default_timezone_set('UTC'); |
344 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
344 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
349 | 349 | } |
350 | 350 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
352 | 352 | } |
353 | 353 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
361 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
361 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
362 | 362 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
363 | 363 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
364 | 364 | $timeelapsed = microtime(true); |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
370 | 370 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
371 | 371 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
372 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
372 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
373 | 373 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
374 | 374 | $Spotter->db = null; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -384,25 +384,25 @@ discard block |
||
384 | 384 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
385 | 385 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
386 | 386 | */ |
387 | - 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'])); |
|
387 | + 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'])); |
|
388 | 388 | |
389 | 389 | //$putinarchive = true; |
390 | 390 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
391 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
391 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
392 | 392 | } |
393 | 393 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
397 | - $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' => '')); |
|
397 | + $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' => '')); |
|
398 | 398 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
399 | 399 | $timeelapsed = microtime(true); |
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | 401 | $Spotter = new Spotter($this->db); |
402 | 402 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
403 | 403 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
404 | - $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' => '')); |
|
405 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
404 | + $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' => '')); |
|
405 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
406 | 406 | } |
407 | 407 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
408 | 408 | $timeelapsed = microtime(true); |
@@ -416,34 +416,34 @@ discard block |
||
416 | 416 | $Translation->db = null; |
417 | 417 | } |
418 | 418 | $Spotter->db = null; |
419 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
420 | 420 | } |
421 | 421 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
422 | 422 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
423 | 423 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
424 | 424 | // $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'])); |
425 | - $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'])); |
|
425 | + $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'])); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | if (!isset($globalFork)) $globalFork = TRUE; |
429 | 429 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
430 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
430 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | if (isset($line['speed']) && $line['speed'] != '') { |
436 | 436 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
437 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
439 | 439 | //$dataFound = true; |
440 | 440 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
441 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
441 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
442 | 442 | if ($distance > 1000 && $distance < 10000) { |
443 | 443 | // use datetime |
444 | 444 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
445 | 445 | $speed = $speed*3.6; |
446 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
446 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
447 | 447 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
448 | 448 | } |
449 | 449 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | |
452 | 452 | |
453 | 453 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
454 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
454 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
455 | 455 | else unset($timediff); |
456 | - 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')))) { |
|
456 | + 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')))) { |
|
457 | 457 | 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'])) { |
458 | - 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'])) { |
|
458 | + 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'])) { |
|
459 | 459 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
460 | 460 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
461 | 461 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | $timeelapsed = microtime(true); |
466 | 466 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
467 | 467 | $Spotter = new Spotter($this->db); |
468 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
468 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
469 | 469 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
470 | 470 | $Spotter->db = null; |
471 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
471 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
472 | 472 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
473 | 473 | } |
474 | 474 | } |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
479 | 479 | //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) { |
480 | 480 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
481 | - 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') { |
|
481 | + 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') { |
|
482 | 482 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
483 | 483 | $dataFound = true; |
484 | 484 | $this->all_flights[$id]['time_last_coord'] = time(); |
485 | 485 | } |
486 | 486 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
487 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
487 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
488 | 488 | /* |
489 | 489 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
490 | 490 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
503 | 503 | //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) { |
504 | 504 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
505 | - 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') { |
|
505 | + 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') { |
|
506 | 506 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
507 | 507 | $dataFound = true; |
508 | 508 | $this->all_flights[$id]['time_last_coord'] = time(); |
509 | 509 | } |
510 | 510 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
511 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
511 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
512 | 512 | /* |
513 | 513 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
514 | 514 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -526,46 +526,46 @@ discard block |
||
526 | 526 | } else if ($globalDebug && $timediff > 30) { |
527 | 527 | $this->tmd = $this->tmd + 1; |
528 | 528 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
529 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
530 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
529 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
530 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
531 | 531 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
532 | 532 | } |
533 | 533 | } |
534 | 534 | if (isset($line['last_update']) && $line['last_update'] != '') { |
535 | 535 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
536 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
536 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
537 | 537 | } |
538 | 538 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
539 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
539 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
540 | 540 | //$dataFound = true; |
541 | 541 | } |
542 | 542 | if (isset($line['format_source']) && $line['format_source'] != '') { |
543 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
543 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
544 | 544 | } |
545 | 545 | if (isset($line['source_name']) && $line['source_name'] != '') { |
546 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
546 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
547 | 547 | } |
548 | 548 | if (isset($line['emergency']) && $line['emergency'] != '') { |
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
550 | 550 | //$dataFound = true; |
551 | 551 | } |
552 | 552 | if (isset($line['ground']) && $line['ground'] != '') { |
553 | 553 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
554 | 554 | // Here we force archive of flight because after ground it's a new one (or should be) |
555 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
557 | - 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'))); |
|
558 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
559 | - 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'])); |
|
555 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
557 | + 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'))); |
|
558 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
559 | + 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'])); |
|
560 | 560 | } |
561 | 561 | if ($line['ground'] != 1) $line['ground'] = 0; |
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
563 | 563 | //$dataFound = true; |
564 | 564 | } |
565 | 565 | if (isset($line['squawk']) && $line['squawk'] != '') { |
566 | 566 | 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'])) { |
567 | 567 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
569 | 569 | $highlight = ''; |
570 | 570 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
571 | 571 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -574,47 +574,47 @@ discard block |
||
574 | 574 | $timeelapsed = microtime(true); |
575 | 575 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
576 | 576 | $Spotter = new Spotter($this->db); |
577 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
577 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
578 | 578 | $Spotter->db = null; |
579 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
579 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
580 | 580 | } |
581 | 581 | //$putinarchive = true; |
582 | 582 | //$highlight = ''; |
583 | 583 | } |
584 | 584 | |
585 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
585 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
586 | 586 | //$dataFound = true; |
587 | 587 | } |
588 | 588 | |
589 | 589 | if (isset($line['altitude']) && $line['altitude'] != '') { |
590 | 590 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
591 | - 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; |
|
592 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
593 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
591 | + 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; |
|
592 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
593 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
594 | 594 | //$dataFound = true; |
595 | 595 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
596 | 596 | } |
597 | 597 | |
598 | 598 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
599 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
599 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if (isset($line['heading']) && $line['heading'] != '') { |
603 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
605 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
603 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
605 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
606 | 606 | //$dataFound = true; |
607 | 607 | } 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']) { |
608 | - $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']); |
|
609 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
610 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
608 | + $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']); |
|
609 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
610 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
611 | 611 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
612 | 612 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
613 | 613 | // If not enough messages and ACARS set heading to 0 |
614 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
614 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
615 | 615 | } |
616 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
617 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
616 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
617 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
618 | 618 | |
619 | 619 | // print_r($this->all_flights[$id]); |
620 | 620 | //gets the callsign from the last hour |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
625 | 625 | $this->all_flights[$id]['lastupdate'] = time(); |
626 | 626 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
627 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
627 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
628 | 628 | //print_r($this->all_flights); |
629 | 629 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
630 | 630 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -635,61 +635,61 @@ discard block |
||
635 | 635 | $SpotterLive = new SpotterLive($this->db); |
636 | 636 | 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')) { |
637 | 637 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
638 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
638 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
639 | 639 | } elseif (isset($line['id'])) { |
640 | 640 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
641 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
641 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
642 | 642 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
643 | 643 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
644 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
644 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
645 | 645 | } else $recent_ident = ''; |
646 | - $SpotterLive->db=null; |
|
646 | + $SpotterLive->db = null; |
|
647 | 647 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
648 | 648 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
649 | 649 | } else $recent_ident = ''; |
650 | 650 | } else { |
651 | 651 | $recent_ident = ''; |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
653 | 653 | } |
654 | 654 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
655 | - if($recent_ident == "") |
|
655 | + if ($recent_ident == "") |
|
656 | 656 | { |
657 | 657 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
658 | 658 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
659 | 659 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
660 | 660 | //adds the spotter data for the archive |
661 | 661 | $ignoreImport = false; |
662 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
662 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
663 | 663 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
664 | 664 | $ignoreImport = true; |
665 | 665 | } |
666 | 666 | } |
667 | 667 | if (count($globalAirportAccept) > 0) { |
668 | 668 | $ignoreImport = true; |
669 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
669 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
670 | 670 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
671 | 671 | $ignoreImport = false; |
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
675 | 675 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
676 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
677 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
676 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
677 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
678 | 678 | $ignoreImport = true; |
679 | 679 | } |
680 | 680 | } |
681 | 681 | } |
682 | 682 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
683 | 683 | $ignoreImport = true; |
684 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
685 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
684 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
685 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
686 | 686 | $ignoreImport = false; |
687 | 687 | } |
688 | 688 | } |
689 | 689 | } |
690 | 690 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
691 | 691 | $ignoreImport = true; |
692 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
692 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
693 | 693 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
694 | 694 | $ignoreImport = false; |
695 | 695 | } |
@@ -701,32 +701,32 @@ discard block |
||
701 | 701 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
702 | 702 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
703 | 703 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
704 | - 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'))); |
|
704 | + 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'))); |
|
705 | 705 | $timeelapsed = microtime(true); |
706 | 706 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
707 | 707 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
708 | 708 | $Spotter = new Spotter($this->db); |
709 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
709 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
710 | 710 | $Spotter->db = null; |
711 | 711 | if ($globalDebug && isset($result)) echo $result."\n"; |
712 | 712 | } |
713 | 713 | } |
714 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
714 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
715 | 715 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
716 | 716 | |
717 | 717 | // Add source stat in DB |
718 | 718 | $Stats = new Stats($this->db); |
719 | 719 | if (!empty($this->stats)) { |
720 | 720 | if ($globalDebug) echo 'Add source stats : '; |
721 | - foreach($this->stats as $date => $data) { |
|
722 | - foreach($data as $source => $sourced) { |
|
721 | + foreach ($this->stats as $date => $data) { |
|
722 | + foreach ($data as $source => $sourced) { |
|
723 | 723 | //print_r($sourced); |
724 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
725 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
724 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
725 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
726 | 726 | if (isset($sourced['msg'])) { |
727 | 727 | if (time() - $sourced['msg']['date'] > 10) { |
728 | 728 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
729 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
729 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
730 | 730 | unset($this->stats[$date][$source]['msg']); |
731 | 731 | } |
732 | 732 | } |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
765 | 765 | $SpotterLive = new SpotterLive($this->db); |
766 | 766 | $SpotterLive->deleteLiveSpotterData(); |
767 | - $SpotterLive->db=null; |
|
767 | + $SpotterLive->db = null; |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | if ($globalDebug) echo " Done\n"; |
771 | 771 | $this->last_delete = time(); |
772 | 772 | } |
773 | 773 | } else { |
774 | - 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')) { |
|
774 | + 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')) { |
|
775 | 775 | $this->all_flights[$id]['id'] = $recent_ident; |
776 | 776 | $this->all_flights[$id]['addedSpotter'] = 1; |
777 | 777 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
780 | 780 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
781 | 781 | $Spotter = new Spotter($this->db); |
782 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
782 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
783 | 783 | $Spotter->db = null; |
784 | 784 | } |
785 | 785 | } |
@@ -805,37 +805,37 @@ discard block |
||
805 | 805 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
806 | 806 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
807 | 807 | |
808 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
808 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
809 | 809 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
810 | 810 | $ignoreImport = true; |
811 | 811 | } |
812 | 812 | } |
813 | 813 | if (count($globalAirportAccept) > 0) { |
814 | 814 | $ignoreImport = true; |
815 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
815 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
816 | 816 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
817 | 817 | $ignoreImport = false; |
818 | 818 | } |
819 | 819 | } |
820 | 820 | } |
821 | 821 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
822 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
823 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
822 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
823 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
824 | 824 | $ignoreImport = true; |
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
828 | 828 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
829 | 829 | $ignoreImport = true; |
830 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
831 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
830 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
831 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
832 | 832 | $ignoreImport = false; |
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
836 | 836 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
837 | 837 | $ignoreImport = true; |
838 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
838 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
839 | 839 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
840 | 840 | $ignoreImport = false; |
841 | 841 | } |
@@ -843,23 +843,23 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | if (!$ignoreImport) { |
846 | - 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'])) { |
|
847 | - 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'))); |
|
846 | + 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'])) { |
|
847 | + 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'))); |
|
848 | 848 | $timeelapsed = microtime(true); |
849 | 849 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
850 | 850 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
851 | 851 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
852 | 852 | $SpotterLive = new SpotterLive($this->db); |
853 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
853 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
854 | 854 | $SpotterLive->db = null; |
855 | 855 | if ($globalDebug) echo $result."\n"; |
856 | 856 | } |
857 | 857 | } |
858 | 858 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
859 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
859 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
860 | 860 | } |
861 | 861 | $this->all_flights[$id]['putinarchive'] = false; |
862 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
862 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
863 | 863 | |
864 | 864 | // Put statistics in $this->stats variable |
865 | 865 | //if ($line['format_source'] != 'aprs') { |
@@ -878,19 +878,19 @@ discard block |
||
878 | 878 | $latitude = $globalCenterLatitude; |
879 | 879 | $longitude = $globalCenterLongitude; |
880 | 880 | } |
881 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
881 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
882 | 882 | } else { |
883 | 883 | $latitude = $this->source_location[$source]['latitude']; |
884 | 884 | $longitude = $this->source_location[$source]['longitude']; |
885 | 885 | } |
886 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
886 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
887 | 887 | //$stats_heading = $stats_heading%22.5; |
888 | 888 | $stats_heading = round($stats_heading/22.5); |
889 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
889 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
890 | 890 | $current_date = date('Y-m-d'); |
891 | 891 | if ($stats_heading == 16) $stats_heading = 0; |
892 | 892 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
893 | - for ($i=0;$i<=15;$i++) { |
|
893 | + for ($i = 0; $i <= 15; $i++) { |
|
894 | 894 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
895 | 895 | } |
896 | 896 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
906 | 906 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
907 | 907 | end($this->stats[$current_date][$source]['hist']); |
908 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
908 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
909 | 909 | } else $mini = 0; |
910 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
910 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
911 | 911 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
912 | 912 | } |
913 | 913 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $this->all_flights[$id]['lastupdate'] = time(); |
921 | 921 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
922 | 922 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
923 | - } 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"; |
|
923 | + } 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"; |
|
924 | 924 | //$this->del(); |
925 | 925 | |
926 | 926 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |