@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | $currentdate = date('Y-m-d'); |
30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
31 | 31 | if (!empty($sourcestat)) { |
32 | - foreach($sourcestat as $srcst) { |
|
32 | + foreach ($sourcestat as $srcst) { |
|
33 | 33 | $type = $srcst['stats_type']; |
34 | 34 | if ($type == 'polar' || $type == 'hist') { |
35 | 35 | $source = $srcst['source_name']; |
36 | 36 | $data = $srcst['source_data']; |
37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
37 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - public function get_Schedule($id,$ident) { |
|
43 | + public function get_Schedule($id, $ident) { |
|
44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 45 | // Get schedule here, so it's done only one time |
46 | 46 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | 67 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | 70 | // Should also check if route schedule = route from DB |
71 | 71 | if ($schedule['DepartureAirportIATA'] != '') { |
72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | - $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']); |
|
89 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
90 | 90 | } |
91 | 91 | } else $scheduleexist = true; |
92 | 92 | } else $scheduleexist = true; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | if ($scheduleexist) { |
95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
96 | 96 | $sch = $Schedule->getSchedule($operator); |
97 | - $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'])); |
|
97 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
98 | 98 | } |
99 | 99 | $Spotter->db = null; |
100 | 100 | $Schedule->db = null; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
121 | 121 | $Spotter = new Spotter($this->db); |
122 | 122 | $real_arrival = $this->arrival($key); |
123 | - $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']); |
|
123 | + $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']); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $airport_time = ''; |
134 | 134 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
137 | 137 | if (isset($closestAirports[0])) { |
138 | 138 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 139 | $airport_icao = $closestAirports[0]['icao']; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
151 | - } 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))) { |
|
151 | + } 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))) { |
|
152 | 152 | $airport_icao = $closestAirports[0]['icao']; |
153 | 153 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 154 | } else { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } else { |
162 | 162 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
163 | 163 | } |
164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
164 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
173 | 173 | foreach ($this->all_flights as $key => $flight) { |
174 | 174 | if (isset($flight['lastupdate'])) { |
175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
175 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
176 | 176 | if (isset($this->all_flights[$key]['id'])) { |
177 | 177 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
178 | 178 | /* |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $real_arrival = $this->arrival($key); |
184 | 184 | $Spotter = new Spotter($this->db); |
185 | 185 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | - $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']); |
|
186 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | } |
189 | 189 | // Put in archive |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $send = false; |
220 | 220 | |
221 | 221 | // SBS format is CSV format |
222 | - if(is_array($line) && isset($line['hex'])) { |
|
222 | + if (is_array($line) && isset($line['hex'])) { |
|
223 | 223 | //print_r($line); |
224 | 224 | if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
225 | 225 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | //print_r($this->all_flights); |
254 | 254 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
255 | 255 | $this->all_flights[$id] = array('hex' => $hex); |
256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
257 | 257 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
258 | 258 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
259 | 259 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $Spotter = new Spotter($this->db); |
264 | 264 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 265 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
266 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
267 | 267 | |
268 | 268 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | 269 | if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
@@ -271,32 +271,32 @@ discard block |
||
271 | 271 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
272 | 272 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
273 | 273 | } |
274 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
274 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
275 | 275 | } else if (isset($line['aircraft_name'])) { |
276 | 276 | // Get aircraft ICAO from aircraft name |
277 | 277 | $Spotter = new Spotter($this->db); |
278 | 278 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 279 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
284 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
281 | + else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
282 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
283 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true)); |
|
284 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
285 | 285 | if (!isset($line['id'])) { |
286 | 286 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
287 | 287 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
288 | 288 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
289 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
290 | 290 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
291 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
292 | 292 | |
293 | 293 | if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
294 | 294 | if ($globalAllFlights !== FALSE) $dataFound = true; |
295 | 295 | } |
296 | 296 | |
297 | - if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
297 | + if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) { |
|
298 | 298 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
299 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
299 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
300 | 300 | } else { |
301 | 301 | 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"; |
302 | 302 | 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"; |
@@ -307,23 +307,23 @@ discard block |
||
307 | 307 | */ |
308 | 308 | return ''; |
309 | 309 | } |
310 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
310 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
311 | 311 | |
312 | 312 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
314 | 314 | } |
315 | 315 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
316 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
316 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
317 | 317 | } |
318 | 318 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
320 | 320 | } |
321 | 321 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
322 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | 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'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
327 | 327 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
328 | 328 | $timeelapsed = microtime(true); |
329 | 329 | $Spotter = new Spotter($this->db); |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
334 | 334 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
335 | 335 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
336 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
336 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
337 | 337 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
338 | 338 | $Spotter->db = null; |
339 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
339 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /* |
@@ -347,24 +347,24 @@ discard block |
||
347 | 347 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 348 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 349 | */ |
350 | - 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'])); |
|
350 | + 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'])); |
|
351 | 351 | |
352 | 352 | //$putinarchive = true; |
353 | 353 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
360 | - $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' => '')); |
|
360 | + $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' => '')); |
|
361 | 361 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
362 | 362 | $timeelapsed = microtime(true); |
363 | 363 | $Spotter = new Spotter($this->db); |
364 | 364 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 365 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | - $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' => '')); |
|
367 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
366 | + $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' => '')); |
|
367 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
368 | 368 | |
369 | 369 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
370 | 370 | $timeelapsed = microtime(true); |
@@ -377,34 +377,34 @@ discard block |
||
377 | 377 | $Translation->db = null; |
378 | 378 | } |
379 | 379 | $Spotter->db = null; |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
381 | 381 | |
382 | 382 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | 383 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
384 | 384 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
385 | 385 | // $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'])); |
386 | - $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'])); |
|
386 | + $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'])); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | if (!isset($globalFork)) $globalFork = TRUE; |
390 | 390 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
391 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | if (isset($line['speed']) && $line['speed'] != '') { |
397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
399 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
399 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
400 | 400 | //$dataFound = true; |
401 | 401 | } 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'])) { |
402 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
402 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
403 | 403 | if ($distance > 1000 && $distance < 10000) { |
404 | 404 | // use datetime |
405 | 405 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 406 | $speed = $speed*3.6; |
407 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
407 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
408 | 408 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
409 | 409 | } |
410 | 410 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
415 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
416 | 416 | else unset($timediff); |
417 | - 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')))) { |
|
417 | + 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')))) { |
|
418 | 418 | 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'])) { |
419 | - 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'])) { |
|
419 | + 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'])) { |
|
420 | 420 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
421 | 421 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 422 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
425 | 425 | $timeelapsed = microtime(true); |
426 | 426 | $Spotter = new Spotter($this->db); |
427 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
427 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
428 | 428 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
429 | 429 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431 | 431 | $this->tmd = 0; |
432 | 432 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
433 | 433 | } |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | 437 | //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) { |
438 | 438 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
439 | - 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') { |
|
439 | + 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') { |
|
440 | 440 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
441 | 441 | $dataFound = true; |
442 | 442 | $this->all_flights[$id]['time_last_coord'] = time(); |
443 | 443 | } |
444 | 444 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
445 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
446 | 446 | /* |
447 | 447 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
448 | 448 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -460,13 +460,13 @@ discard block |
||
460 | 460 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
461 | 461 | //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) { |
462 | 462 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
463 | - 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') { |
|
463 | + 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') { |
|
464 | 464 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
465 | 465 | $dataFound = true; |
466 | 466 | $this->all_flights[$id]['time_last_coord'] = time(); |
467 | 467 | } |
468 | 468 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
469 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
469 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
470 | 470 | /* |
471 | 471 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
472 | 472 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -484,45 +484,45 @@ discard block |
||
484 | 484 | } else if ($globalDebug && $timediff > 20) { |
485 | 485 | $this->tmd = $this->tmd + 1; |
486 | 486 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
487 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
488 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
487 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
488 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
489 | 489 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | 493 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
495 | 495 | } |
496 | 496 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
497 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
498 | 498 | //$dataFound = true; |
499 | 499 | } |
500 | 500 | if (isset($line['format_source']) && $line['format_source'] != '') { |
501 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
501 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
502 | 502 | } |
503 | 503 | if (isset($line['source_name']) && $line['source_name'] != '') { |
504 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
504 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
505 | 505 | } |
506 | 506 | if (isset($line['emergency']) && $line['emergency'] != '') { |
507 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
508 | 508 | //$dataFound = true; |
509 | 509 | } |
510 | 510 | if (isset($line['ground']) && $line['ground'] != '') { |
511 | 511 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
512 | 512 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
514 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
515 | - 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'))); |
|
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | - 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'])); |
|
513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
514 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
515 | + 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'))); |
|
516 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
517 | + 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'])); |
|
518 | 518 | } |
519 | 519 | if ($line['ground'] != 1) $line['ground'] = 0; |
520 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
521 | 521 | //$dataFound = true; |
522 | 522 | } |
523 | 523 | if (isset($line['squawk']) && $line['squawk'] != '') { |
524 | 524 | 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'])) { |
525 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
526 | 526 | $highlight = ''; |
527 | 527 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
528 | 528 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -530,48 +530,48 @@ discard block |
||
530 | 530 | if ($highlight != '') { |
531 | 531 | $timeelapsed = microtime(true); |
532 | 532 | $Spotter = new Spotter($this->db); |
533 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
533 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
534 | 534 | $Spotter->db = null; |
535 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
536 | 536 | |
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 538 | //$putinarchive = true; |
539 | 539 | //$highlight = ''; |
540 | 540 | } |
541 | 541 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
542 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
543 | 543 | //$dataFound = true; |
544 | 544 | } |
545 | 545 | |
546 | 546 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | 547 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
548 | - 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; |
|
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
550 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
548 | + 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; |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
550 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
551 | 551 | //$dataFound = true; |
552 | 552 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
553 | 553 | } |
554 | 554 | |
555 | 555 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
560 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
563 | 563 | //$dataFound = true; |
564 | 564 | } 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']) { |
565 | - $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']); |
|
566 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
565 | + $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']); |
|
566 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
567 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | 568 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
569 | 569 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | 570 | // If not enough messages and ACARS set heading to 0 |
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
572 | 572 | } |
573 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
573 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
575 | 575 | |
576 | 576 | // print_r($this->all_flights[$id]); |
577 | 577 | //gets the callsign from the last hour |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
582 | 582 | $this->all_flights[$id]['lastupdate'] = time(); |
583 | 583 | if ($this->all_flights[$id]['addedSpotter'] == 0) { |
584 | - 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'])) { |
|
584 | + 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'])) { |
|
585 | 585 | //print_r($this->all_flights); |
586 | 586 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
587 | 587 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -591,61 +591,61 @@ discard block |
||
591 | 591 | $SpotterLive = new SpotterLive($this->db); |
592 | 592 | 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')) { |
593 | 593 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
595 | 595 | } elseif (isset($line['id'])) { |
596 | 596 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
597 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
598 | 598 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | 599 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
600 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
601 | 601 | } else $recent_ident = ''; |
602 | - $SpotterLive->db=null; |
|
602 | + $SpotterLive->db = null; |
|
603 | 603 | |
604 | 604 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
605 | 605 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
606 | 606 | } else { |
607 | 607 | $recent_ident = ''; |
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
609 | 609 | } |
610 | 610 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
611 | - if($recent_ident == "") |
|
611 | + if ($recent_ident == "") |
|
612 | 612 | { |
613 | 613 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
614 | 614 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 615 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 616 | //adds the spotter data for the archive |
617 | 617 | $ignoreImport = false; |
618 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
618 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
619 | 619 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
620 | 620 | $ignoreImport = true; |
621 | 621 | } |
622 | 622 | } |
623 | 623 | if (count($globalAirportAccept) > 0) { |
624 | 624 | $ignoreImport = true; |
625 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
625 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
626 | 626 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
627 | 627 | $ignoreImport = false; |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | 631 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
632 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
633 | - 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)) { |
|
632 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
633 | + 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)) { |
|
634 | 634 | $ignoreImport = true; |
635 | 635 | } |
636 | 636 | } |
637 | 637 | } |
638 | 638 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
639 | 639 | $ignoreImport = true; |
640 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
641 | - 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)) { |
|
640 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
641 | + 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)) { |
|
642 | 642 | $ignoreImport = false; |
643 | 643 | } |
644 | 644 | } |
645 | 645 | } |
646 | 646 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
647 | 647 | $ignoreImport = true; |
648 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
648 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
649 | 649 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
650 | 650 | $ignoreImport = false; |
651 | 651 | } |
@@ -657,27 +657,27 @@ discard block |
||
657 | 657 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
658 | 658 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
659 | 659 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
660 | - 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'))); |
|
660 | + 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'))); |
|
661 | 661 | $timeelapsed = microtime(true); |
662 | 662 | $Spotter = new Spotter($this->db); |
663 | - $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']); |
|
663 | + $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']); |
|
664 | 664 | $Spotter->db = null; |
665 | 665 | if ($globalDebug && isset($result)) echo $result."\n"; |
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
666 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
667 | 667 | |
668 | 668 | // Add source stat in DB |
669 | 669 | $Stats = new Stats($this->db); |
670 | 670 | if (!empty($this->stats)) { |
671 | 671 | if ($globalDebug) echo 'Add source stats : '; |
672 | - foreach($this->stats as $date => $data) { |
|
673 | - foreach($data as $source => $sourced) { |
|
672 | + foreach ($this->stats as $date => $data) { |
|
673 | + foreach ($data as $source => $sourced) { |
|
674 | 674 | //print_r($sourced); |
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
675 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
676 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
677 | 677 | if (isset($sourced['msg'])) { |
678 | 678 | if (time() - $sourced['msg']['date'] > 10) { |
679 | 679 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
680 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
680 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
681 | 681 | unset($this->stats[$date][$source]['msg']); |
682 | 682 | } |
683 | 683 | } |
@@ -713,18 +713,18 @@ discard block |
||
713 | 713 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
714 | 714 | $SpotterLive = new SpotterLive($this->db); |
715 | 715 | $SpotterLive->deleteLiveSpotterData(); |
716 | - $SpotterLive->db=null; |
|
716 | + $SpotterLive->db = null; |
|
717 | 717 | if ($globalDebug) echo " Done\n"; |
718 | 718 | $this->last_delete = time(); |
719 | 719 | } |
720 | 720 | } else { |
721 | - 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')) { |
|
721 | + 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')) { |
|
722 | 722 | $this->all_flights[$id]['id'] = $recent_ident; |
723 | 723 | $this->all_flights[$id]['addedSpotter'] = 1; |
724 | 724 | } |
725 | 725 | if (isset($globalDaemon) && !$globalDaemon) { |
726 | 726 | $Spotter = new Spotter($this->db); |
727 | - $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]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
727 | + $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]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
728 | 728 | $Spotter->db = null; |
729 | 729 | } |
730 | 730 | |
@@ -748,37 +748,37 @@ discard block |
||
748 | 748 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
749 | 749 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
750 | 750 | |
751 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
751 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
752 | 752 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
753 | 753 | $ignoreImport = true; |
754 | 754 | } |
755 | 755 | } |
756 | 756 | if (count($globalAirportAccept) > 0) { |
757 | 757 | $ignoreImport = true; |
758 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
758 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
759 | 759 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
760 | 760 | $ignoreImport = false; |
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
764 | 764 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
765 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
766 | - 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)) { |
|
765 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
766 | + 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)) { |
|
767 | 767 | $ignoreImport = true; |
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
772 | 772 | $ignoreImport = true; |
773 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
774 | - 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)) { |
|
773 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
774 | + 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)) { |
|
775 | 775 | $ignoreImport = false; |
776 | 776 | } |
777 | 777 | } |
778 | 778 | } |
779 | 779 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
780 | 780 | $ignoreImport = true; |
781 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
781 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
782 | 782 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
783 | 783 | $ignoreImport = false; |
784 | 784 | } |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | } |
787 | 787 | |
788 | 788 | if (!$ignoreImport) { |
789 | - 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'])) { |
|
789 | + 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'])) { |
|
790 | 790 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
791 | 791 | $timeelapsed = microtime(true); |
792 | 792 | $SpotterLive = new SpotterLive($this->db); |
793 | - $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']); |
|
793 | + $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']); |
|
794 | 794 | $SpotterLive->db = null; |
795 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
795 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
796 | 796 | |
797 | 797 | // Put statistics in $this->stats variable |
798 | 798 | //if ($line['format_source'] != 'aprs') { |
@@ -810,19 +810,19 @@ discard block |
||
810 | 810 | $latitude = $globalCenterLatitude; |
811 | 811 | $longitude = $globalCenterLongitude; |
812 | 812 | } |
813 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
813 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
814 | 814 | } else { |
815 | 815 | $latitude = $this->source_location[$source]['latitude']; |
816 | 816 | $longitude = $this->source_location[$source]['longitude']; |
817 | 817 | } |
818 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
818 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
819 | 819 | //$stats_heading = $stats_heading%22.5; |
820 | 820 | $stats_heading = round($stats_heading/22.5); |
821 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
821 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
822 | 822 | $current_date = date('Y-m-d'); |
823 | 823 | if ($stats_heading == 16) $stats_heading = 0; |
824 | 824 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | - for ($i=0;$i<=15;$i++) { |
|
825 | + for ($i = 0; $i <= 15; $i++) { |
|
826 | 826 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
827 | 827 | } |
828 | 828 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -837,9 +837,9 @@ discard block |
||
837 | 837 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
838 | 838 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | 839 | end($this->stats[$current_date][$source]['hist']); |
840 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
840 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
841 | 841 | } else $mini = 0; |
842 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
842 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
843 | 843 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
844 | 844 | } |
845 | 845 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
853 | 853 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
854 | 854 | if ($globalDebug) echo $result."\n"; |
855 | - } 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"; |
|
855 | + } 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"; |
|
856 | 856 | //$this->del(); |
857 | 857 | |
858 | 858 |