Exemplo n.º 1
0
 static function add($line)
 {
     global $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug;
     date_default_timezone_set('UTC');
     // signal handler - playing nice with sockets and dump1090
     // pcntl_signal_dispatch();
     // get the time (so we can figure the timeout)
     $time = time();
     //pcntl_signal_dispatch();
     $dataFound = false;
     $putinarchive = false;
     $send = false;
     // SBS format is CSV format
     if (is_array($line) && isset($line['hex'])) {
         //print_r($line);
         if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) == 6) {
             $hex = trim($line['hex']);
             $id = trim($line['hex']);
             //print_r(self::$all_flights);
             if (!isset(self::$all_flights[$id]['hex'])) {
                 self::$all_flights[$id] = array('hex' => $hex, 'datetime' => $line['datetime']);
                 if (!isset($line['aircraft_icao'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('aircraft_icao' => Spotter::getAllAircraftType($hex)));
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => ''));
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('lastupdate' => time()));
                 if ($globalDebug) {
                     echo "*********** New aircraft hex : " . $hex . " ***********\n";
                 }
             }
             if (isset($line['datetime']) && $line['datetime'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('datetime' => $line['datetime']));
             }
             if (isset($line['registration']) && $line['registration'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('registration' => $line['registration']));
             }
             if (isset($line['waypoints']) && $line['waypoints'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('waypoints' => $line['waypoints']));
             }
             if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('pilot_id' => $line['pilot_id']));
             }
             if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('pilot_name' => $line['pilot_name']));
             }
             if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && self::$all_flights[$id]['ident'] != trim($line['ident'])) {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('ident' => trim($line['ident'])));
                 if (!isset($line['id'])) {
                     if (!isset($globalDaemon)) {
                         $globalDaemon = TRUE;
                     }
                     if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) {
                         self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => self::$all_flights[$id]['hex'] . '-' . self::$all_flights[$id]['ident'] . '-' . date('YmdGi')));
                     } else {
                         self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => self::$all_flights[$id]['hex'] . '-' . self::$all_flights[$id]['ident']));
                     }
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => $line['id']));
                 }
                 $putinarchive = true;
                 if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
                 } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
                     $line['departure_airport_icao'] = Spotter::getAirportIcao($line['departure_airport_iata']);
                     $line['arrival_airport_icao'] = Spotter::getAirportIcao($line['arrival_airport_iata']);
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
                 } else {
                     $route = Spotter::getRouteInfo(trim($line['ident']));
                     if (count($route) > 0) {
                         //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
                         if ($route['fromairport_icao'] != $route['toairport_icao']) {
                             //    self::$all_flights[$id] = array_merge(self::$all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
                             self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
                         }
                     }
                     if (!isset($globalFork)) {
                         $globalFork = TRUE;
                     }
                     if (function_exists('pcntl_fork') && $globalFork) {
                         $pids[$id] = pcntl_fork();
                         if (!$pids[$id]) {
                             $sid = posix_setsid();
                             SBS::get_Schedule($id, trim($line['ident']));
                             exit(0);
                         }
                     }
                 }
             }
             if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
                 if (!isset(self::$all_flights[$id]['latitude']) || self::$all_flights[$id]['latitude'] == '' || abs(self::$all_flights[$id]['latitude'] - $line['latitude']) < 3 || $line['format_source'] != 'sbs') {
                     if (!isset(self::$all_flights[$id]['archive_latitude'])) {
                         self::$all_flights[$id]['archive_latitude'] = $line['latitude'];
                     }
                     if (!isset(self::$all_flights[$id]['livedb_latitude']) || abs(self::$all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.02) {
                         self::$all_flights[$id]['livedb_latitude'] = $line['latitude'];
                         $dataFound = true;
                     }
                     // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('latitude' => $line['latitude']));
                     if (abs(self::$all_flights[$id]['archive_latitude'] - self::$all_flights[$id]['latitude']) > 0.3) {
                         self::$all_flights[$id]['archive_latitude'] = $line['latitude'];
                         $putinarchive = true;
                     }
                 } elseif (isset(self::$all_flights[$id]['latitude'])) {
                     if ($globalDebug) {
                         echo '!!! Strange latitude value - diff : ' . abs(self::$all_flights[$id]['latitude'] - $line['latitude']) . '- previous lat : ' . self::$all_flights[$id]['latitude'] . '- new lat : ' . $line['latitude'] . "\n";
                     }
                 }
             }
             if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
                 if ($line['longitude'] > 180) {
                     $line['longitude'] = $line['longitude'] - 360;
                 }
                 if (!isset(self::$all_flights[$id]['longitude']) || self::$all_flights[$id]['longitude'] == '' || abs(self::$all_flights[$id]['longitude'] - $line['longitude']) < 2 || $line['format_source'] != 'sbs') {
                     if (!isset(self::$all_flights[$id]['archive_longitude'])) {
                         self::$all_flights[$id]['archive_longitude'] = $line['longitude'];
                     }
                     if (!isset(self::$all_flights[$id]['livedb_longitude']) || abs(self::$all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.02) {
                         self::$all_flights[$id]['livedb_longitude'] = $line['longitude'];
                         $dataFound = true;
                     }
                     // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('longitude' => $line['longitude']));
                     if (abs(self::$all_flights[$id]['archive_longitude'] - self::$all_flights[$id]['longitude']) > 0.3) {
                         self::$all_flights[$id]['archive_longitude'] = $line['longitude'];
                         $putinarchive = true;
                     }
                 } elseif (isset(self::$all_flights[$id]['longitude'])) {
                     if ($globalDebug) {
                         echo '!!! Strange longitude value - diff : ' . abs(self::$all_flights[$id]['longitude'] - $line['longitude']) . '- previous lat : ' . self::$all_flights[$id]['longitude'] . '- new lat : ' . $line['longitude'] . "\n";
                     }
                 }
             }
             if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('verticalrate' => $line['verticalrate']));
                 //$dataFound = true;
             }
             if (isset($line['emergency']) && $line['emergency'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('emergency' => $line['emergency']));
                 //$dataFound = true;
             }
             if (isset($line['speed']) && $line['speed'] != '') {
                 //    self::$all_flights[$id] = array_merge(self::$all_flights[$id],array('speed' => $line[12]));
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('speed' => round($line['speed'])));
                 //$dataFound = true;
             }
             if (isset($line['squawk']) && $line['squawk'] != '') {
                 if (isset(self::$all_flights[$id]['squawk']) && self::$all_flights[$id]['squawk'] != '7500' && self::$all_flights[$id]['squawk'] != '7600' && self::$all_flights[$id]['squawk'] != '7700' && isset(self::$all_flights[$id]['id'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('squawk' => $line['squawk']));
                     $highlight = '';
                     if (self::$all_flights[$id]['squawk'] == '7500') {
                         $highlight = 'Squawk 7500 : Hijack at ' . date('G:i') . ' UTC';
                     }
                     if (self::$all_flights[$id]['squawk'] == '7600') {
                         $highlight = 'Squawk 7600 : Lost Comm (radio failure) at ' . date('G:i') . ' UTC';
                     }
                     if (self::$all_flights[$id]['squawk'] == '7700') {
                         $highlight = 'Squawk 7700 : Emergency at ' . date('G:i') . ' UTC';
                     }
                     if ($highlight != '') {
                         Spotter::setHighlightFlight(self::$all_flights[$id]['id'], $highlight);
                         $putinarchive = true;
                         $highlight = '';
                     }
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('squawk' => $line['squawk']));
                 }
                 //$dataFound = true;
             }
             if (isset($line['altitude']) && $line['altitude'] != '') {
                 //if (!isset(self::$all_flights[$id]['altitude']) || self::$all_flights[$id]['altitude'] == '' || (self::$all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
                 if (abs(round($line['altitude'] / 100) - self::$all_flights[$id]['altitude']) > 2) {
                     $putinarchive = true;
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('altitude' => round($line['altitude'] / 100)));
                 //$dataFound = true;
                 //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
             }
             if (isset($line['heading']) && $line['heading'] != '') {
                 if (abs(self::$all_flights[$id]['heading'] - round($line['heading'])) > 2) {
                     $putinarchive = true;
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('heading' => round($line['heading'])));
                 //$dataFound = true;
             }
             if (isset($globalSBS1update) && $globalSBS1update != '' && isset(self::$all_flights[$id]['lastupdate']) && time() - self::$all_flights[$id]['lastupdate'] < $globalSBS1update) {
                 $dataFound = false;
             }
             //		print_r(self::$all_flights[$id]);
             //gets the callsign from the last hour
             //if (time()-self::$all_flights[$id]['lastupdate'] > 30 && $dataFound == true && self::$all_flights[$id]['ident'] != '' && self::$all_flights[$id]['latitude'] != '' && self::$all_flights[$id]['longitude'] != '') {
             if ($dataFound == true && isset(self::$all_flights[$id]['hex']) && self::$all_flights[$id]['ident'] != '' && self::$all_flights[$id]['latitude'] != '' && self::$all_flights[$id]['longitude'] != '') {
                 if (!isset($globalDistanceIgnore['latitude']) || isset($globalDistanceIgnore['latitude']) && Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance']) {
                     self::$all_flights[$id]['lastupdate'] = time();
                     //$last_hour_ident = Spotter::getIdentFromLastHour(self::$all_flights[$id]['ident']);
                     $recent_ident = SpotterLive::checkIdentRecent(self::$all_flights[$id]['ident']);
                     //if there was no aircraft with the same callsign within the last hour and go post it into the archive
                     if ($recent_ident == "") {
                         if ($globalDebug) {
                             echo "\\o/ Add " . self::$all_flights[$id]['ident'] . " in archive DB : ";
                         }
                         if (self::$all_flights[$id]['departure_airport'] == "") {
                             self::$all_flights[$id]['departure_airport'] = "NA";
                         }
                         if (self::$all_flights[$id]['arrival_airport'] == "") {
                             self::$all_flights[$id]['arrival_airport'] = "NA";
                         }
                         //adds the spotter data for the archive
                         $ignoreImport = false;
                         foreach ($globalAirportIgnore as $airportIgnore) {
                             if (self::$all_flights[$id]['departure_airport'] != $airportIgnore && self::$all_flights[$id]['arrival_airport'] != $airportIgnore) {
                                 $ignoreImport = true;
                             }
                         }
                         if (!$ignoreImport) {
                             $highlight = '';
                             if (self::$all_flights[$id]['squawk'] == '7500') {
                                 $highlight = 'Squawk 7500 : Hijack';
                             }
                             if (self::$all_flights[$id]['squawk'] == '7600') {
                                 $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
                             }
                             if (self::$all_flights[$id]['squawk'] == '7700') {
                                 $highlight = 'Squawk 7700 : Emergency';
                             }
                             $result = Spotter::addSpotterData(self::$all_flights[$id]['id'], self::$all_flights[$id]['ident'], self::$all_flights[$id]['aircraft_icao'], self::$all_flights[$id]['departure_airport'], self::$all_flights[$id]['arrival_airport'], self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], self::$all_flights[$id]['waypoints'], self::$all_flights[$id]['altitude'], self::$all_flights[$id]['heading'], self::$all_flights[$id]['speed'], '', self::$all_flights[$id]['departure_airport_time'], self::$all_flights[$id]['arrival_airport_time'], self::$all_flights[$id]['squawk'], self::$all_flights[$id]['route_stop'], $highlight, self::$all_flights[$id]['hex'], self::$all_flights[$id]['registration'], self::$all_flights[$id]['pilot_id'], self::$all_flights[$id]['pilot_name']);
                         }
                         $ignoreImport = false;
                         if ($globalDebug) {
                             echo $result . "\n";
                         }
                         /*
                         if (isset($globalArchive) && $globalArchive) {
                             $archives_ident = SpotterLive::getAllLiveSpotterDataByIdent(self::$all_flights[$id]['ident']);
                             foreach ($archives_ident as $archive) {
                         	SpotterArchive::addSpotterArchiveData($archive['flightaware_id'], $archive['ident'], $archive['registration'],$archive['airline_name'],$archive['airline_icao'],$archive['airline_country'],$archive['airline_type'],$archive['aircraft_icao'],$archive['aircraft_shadow'],$archive['aircraft_name'],$archive['aircraft_manufacturer'], $archive['departure_airport_icao'],$archive['departure_airport_name'],$archive['departure_airport_city'],$archive['departure_airport_country'],$archive['departure_airport_time'],
                         	$archive['arrival_airport_icao'],$archive['arrival_airport_name'],$archive['arrival_airport_city'],$archive['arrival_airport_country'],$archive['arrival_airport_time'],
                         	$archive['route_stop'],$archive['date'],$archive['latitude'], $archive['longitude'], $archive['waypoints'], $archive['altitude'], $archive['heading'], $archive['ground_speed'],
                         	$archive['squawk'],$archive['ModeS']);
                             }
                         }
                         */
                         //SpotterLive::deleteLiveSpotterDataByIdent(self::$all_flights[$id]['ident']);
                         SpotterLive::deleteLiveSpotterData();
                     }
                 }
                 //adds the spotter LIVE data
                 //SpotterLive::addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
                 //echo "\nAdd in Live !! \n";
                 //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
                 if ($globalDebug) {
                     echo 'DATA : hex : ' . self::$all_flights[$id]['hex'] . ' - ident : ' . self::$all_flights[$id]['ident'] . ' - ICAO : ' . self::$all_flights[$id]['aircraft_icao'] . ' - Departure Airport : ' . self::$all_flights[$id]['departure_airport'] . ' - Arrival Airport : ' . self::$all_flights[$id]['arrival_airport'] . ' - Latitude : ' . self::$all_flights[$id]['latitude'] . ' - Longitude : ' . self::$all_flights[$id]['longitude'] . ' - waypoints : ' . self::$all_flights[$id]['waypoints'] . ' - Altitude : ' . self::$all_flights[$id]['altitude'] . ' - Heading : ' . self::$all_flights[$id]['heading'] . ' - Speed : ' . self::$all_flights[$id]['speed'] . ' - Departure Airport Time : ' . self::$all_flights[$id]['departure_airport_time'] . ' - Arrival Airport time : ' . self::$all_flights[$id]['arrival_airport_time'] . "\n";
                 }
                 $ignoreImport = false;
                 if (self::$all_flights[$id]['departure_airport'] == "") {
                     self::$all_flights[$id]['departure_airport'] = "NA";
                 }
                 if (self::$all_flights[$id]['arrival_airport'] == "") {
                     self::$all_flights[$id]['arrival_airport'] = "NA";
                 }
                 foreach ($globalAirportIgnore as $airportIgnore) {
                     if (self::$all_flights[$id]['departure_airport'] != $airportIgnore && self::$all_flights[$id]['arrival_airport'] != $airportIgnore) {
                         $ignoreImport = true;
                     }
                 }
                 if (!$ignoreImport) {
                     if (!isset($globalDistanceIgnore['latitude']) || isset($globalDistanceIgnore['latitude']) && Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance']) {
                         if ($globalDebug) {
                             echo "\\o/ Add " . self::$all_flights[$id]['ident'] . " in Live DB : ";
                         }
                         $result = SpotterLive::addLiveSpotterData(self::$all_flights[$id]['id'], self::$all_flights[$id]['ident'], self::$all_flights[$id]['aircraft_icao'], self::$all_flights[$id]['departure_airport'], self::$all_flights[$id]['arrival_airport'], self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], self::$all_flights[$id]['waypoints'], self::$all_flights[$id]['altitude'], self::$all_flights[$id]['heading'], self::$all_flights[$id]['speed'], self::$all_flights[$id]['departure_airport_time'], self::$all_flights[$id]['arrival_airport_time'], self::$all_flights[$id]['squawk'], self::$all_flights[$id]['route_stop'], self::$all_flights[$id]['hex'], $putinarchive, self::$all_flights[$id]['registration'], self::$all_flights[$id]['pilot_id'], self::$all_flights[$id]['pilot_name']);
                         if ($putinarchive) {
                             $send = true;
                         }
                         //if ($globalDebug) echo "Distance : ".Common::distance(self::$all_flights[$id]['latitude'],self::$all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
                         if ($globalDebug) {
                             echo $result . "\n";
                         }
                     } elseif (isset(self::$all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
                         echo "!! Too far -> Distance : " . Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) . "\n";
                     }
                     self::del();
                 }
                 $ignoreImport = false;
             }
             if (function_exists('pcntl_fork') && $globalFork) {
                 pcntl_signal(SIGCHLD, SIG_IGN);
             }
             if ($send) {
                 return self::$all_flights[$id];
             }
         }
     }
 }
 function add($line)
 {
     global $globalDebug, $globalServerUserID;
     date_default_timezone_set('UTC');
     if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) {
         if (is_array($line) && isset($line['hex'])) {
             if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
                 $data['hex'] = trim($line['hex']);
                 if (preg_match('/^(\\d{4}(?:\\-\\d{2}){2} \\d{2}(?:\\:\\d{2}){2})$/', $line['datetime'])) {
                     $data['datetime'] = $line['datetime'];
                 } else {
                     $data['datetime'] = date('Y-m-d H:i:s');
                 }
                 if (!isset($line['aircraft_icao'])) {
                     $Spotter = new Spotter();
                     $aircraft_icao = $Spotter->getAllAircraftType($data['hex']);
                     $Spotter->db = null;
                     if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
                         if ($line['aircraft_type'] == 'PARA_GLIDER') {
                             $aircraft_icao = 'GLID';
                         } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
                             $aircraft_icao = 'UHEL';
                         } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
                             $aircraft_icao = 'TOWPLANE';
                         } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
                             $aircraft_icao = 'POWAIRC';
                         }
                     }
                     $data['aircraft_icao'] = $aircraft_icao;
                 } else {
                     $data['aircraft_icao'] = $line['aircraft_icao'];
                 }
                 //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n";
             }
             if (isset($line['registration']) && $line['registration'] != '') {
                 $data['registration'] = $line['registration'];
             } else {
                 $data['registration'] = null;
             }
             if (isset($line['waypoints']) && $line['waypoints'] != '') {
                 $data['waypoints'] = $line['waypoints'];
             } else {
                 $data['waypoints'] = null;
             }
             if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
                 $data['ident'] = trim($line['ident']);
             } else {
                 $data['ident'] = null;
             }
             if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
                 if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
                     $data['latitude'] = $line['latitude'];
                 } else {
                     $data['latitude'] = null;
                 }
                 if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
                     if ($line['longitude'] > 180) {
                         $line['longitude'] = $line['longitude'] - 360;
                     }
                     $data['longitude'] = $line['longitude'];
                 } else {
                     $data['longitude'] = null;
                 }
             } else {
                 $data['latitude'] = null;
                 $data['longitude'] = null;
             }
             if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
                 $data['verticalrate'] = $line['verticalrate'];
             } else {
                 $data['verticalrate'] = null;
             }
             if (isset($line['emergency']) && $line['emergency'] != '') {
                 $data['emergency'] = $line['emergency'];
             } else {
                 $data['emergency'] = null;
             }
             if (isset($line['ground']) && $line['ground'] != '') {
                 $data['ground'] = $line['ground'];
             } else {
                 $data['ground'] = null;
             }
             if (isset($line['speed']) && $line['speed'] != '') {
                 $data['speed'] = round($line['speed']);
             } else {
                 $data['speed'] = null;
             }
             if (isset($line['squawk']) && $line['squawk'] != '') {
                 $data['squawk'] = $line['squawk'];
             } else {
                 $data['squawk'] = null;
             }
             if (isset($line['altitude']) && $line['altitude'] != '') {
                 $data['altitude'] = round($line['altitude']);
             } else {
                 $data['altitude'] = null;
             }
             if (isset($line['heading']) && $line['heading'] != '') {
                 $data['heading'] = round($line['heading']);
             } else {
                 $data['heading'] = null;
             }
             if (isset($line['noarchive']) && $line['noarchive']) {
                 $data['noarchive'] = true;
             } else {
                 $data['noarchive'] = false;
             }
             $id_user = $globalServerUserID;
             $id_source = 1;
             $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive)';
             $query_values = array(':id_user' => $id_user, ':datetime' => $data['datetime'], ':hex' => $data['hex'], ':ident' => $data['ident'], ':latitude' => $data['latitude'], ':longitude' => $data['longitude'], ':verticalrate' => $data['verticalrate'], ':speed' => $data['speed'], ':squawk' => $data['squawk'], ':altitude' => $data['altitude'], ':heading' => $data['heading'], ':registration' => $data['registration'], ':aircraft_icao' => $data['aircraft_icao'], ':waypoints' => $data['waypoints'], ':id_source' => $id_source, ':noarchive' => $data['noarchive']);
             try {
                 $sth = $this->dbs['server']->prepare($query);
                 $sth->execute($query_values);
             } catch (PDOException $e) {
                 return "error : " . $e->getMessage();
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Adds a new spotter data
  *
  * @param String $flightaware_id the ID from flightaware
  * @param String $ident the flight ident
  * @param String $aircraft_icao the aircraft type
  * @param String $departure_airport_icao the departure airport
  * @param String $arrival_airport_icao the arrival airport
  * @return String success or false
  *
  */
 public static function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '')
 {
     global $globalURL, $globalIVAO;
     if (!isset($globalIVAO)) {
         $globalIVAO = FALSE;
     }
     date_default_timezone_set('UTC');
     //getting the registration
     if ($flightaware_id != "" && $registration == '') {
         if (!is_string($flightaware_id)) {
             return false;
         } else {
             if ($ModeS != '') {
                 $registration = Spotter::getAircraftRegistrationBymodeS($ModeS);
             } else {
                 $myhex = explode('-', $flightaware_id);
                 if (count($myhex) > 0) {
                     $registration = Spotter::getAircraftRegistrationBymodeS($myhex[0]);
                 }
             }
         }
     }
     //getting the airline information
     if ($ident != "") {
         if (!is_string($ident)) {
             return false;
         } else {
             if (!is_numeric(substr($ident, 0, 3))) {
                 if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
                     $airline_array = Spotter::getAllAirlineInfo(substr($ident, 0, 2));
                 } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
                     $airline_array = Spotter::getAllAirlineInfo(substr($ident, 0, 3));
                 } else {
                     $airline_array = Spotter::getAllAirlineInfo("NA");
                 }
                 if (count($airline_array) == 0) {
                     $airline_array = Spotter::getAllAirlineInfo("NA");
                 }
                 if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
                     $airline_array = Spotter::getAllAirlineInfo("NA");
                 }
             } else {
                 $airline_array = Spotter::getAllAirlineInfo("NA");
             }
         }
     }
     //getting the aircraft information
     if ($aircraft_icao != "") {
         if (!is_string($aircraft_icao)) {
             return false;
         } else {
             if ($aircraft_icao == "" || $aircraft_icao == "XXXX") {
                 $aircraft_array = Spotter::getAllAircraftInfo("NA");
             } else {
                 $aircraft_array = Spotter::getAllAircraftInfo($aircraft_icao);
             }
         }
     } else {
         if ($flightaware_id != "") {
             $myhex = explode('-', $flightaware_id);
             if (count($myhex) > 0) {
                 $aircraft_icao = Spotter::getAllAircraftType($myhex[0]);
                 if ($aircraft_icao == "" || $aircraft_icao == "XXXX") {
                     $aircraft_array = Spotter::getAllAircraftInfo("NA");
                 } else {
                     $aircraft_array = Spotter::getAllAircraftInfo($aircraft_icao);
                 }
             }
         }
     }
     //getting the departure airport information
     if ($departure_airport_icao != "") {
         if (!is_string($departure_airport_icao)) {
             return false;
         } else {
             $departure_airport_array = Spotter::getAllAirportInfo($departure_airport_icao);
         }
     }
     //getting the arrival airport information
     if ($arrival_airport_icao != "") {
         if (!is_string($arrival_airport_icao)) {
             return false;
         } else {
             $arrival_airport_array = Spotter::getAllAirportInfo($arrival_airport_icao);
         }
     }
     if ($latitude != "") {
         if (!is_numeric($latitude)) {
             return false;
         }
     }
     if ($longitude != "") {
         if (!is_numeric($longitude)) {
             return false;
         }
     }
     if ($waypoints != "") {
         if (!is_string($waypoints)) {
             return false;
         }
     }
     if ($altitude != "") {
         if (!is_numeric($altitude)) {
             return false;
         }
     }
     if ($heading != "") {
         if (!is_numeric($heading)) {
             return false;
         }
     }
     if ($groundspeed != "") {
         if (!is_numeric($groundspeed)) {
             return false;
         }
     }
     if ($date == "") {
         $date = date("Y-m-d H:i:s", time());
     }
     //getting the aircraft image
     if (($registration != "" || $registration != 'NA') && !$globalIVAO) {
         $image_array = Image::getSpotterImage($registration);
         if (!isset($image_array[0]['registration'])) {
             //echo "Add image !!!! \n";
             Image::addSpotterImage($registration);
         }
     }
     if ($globalIVAO && $aircraft_icao != '') {
         if (isset($airline_array[0]['icao'])) {
             $airline_icao = $airline_array[0]['icao'];
         } else {
             $airline_icao = '';
         }
         $image_array = Image::getSpotterImage('', $aircraft_icao, $airline_icao);
         if (!isset($image_array[0]['registration'])) {
             //echo "Add image !!!! \n";
             Image::addSpotterImage('', $aircraft_icao, $airline_icao);
         }
     }
     $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
     $ident = filter_var($ident, FILTER_SANITIZE_STRING);
     $registration = filter_var($registration, FILTER_SANITIZE_STRING);
     $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
     $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
     $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
     $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
     $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
     $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
     $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
     $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
     $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
     $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
     if (count($airline_array) == 0) {
         $airline_array = Spotter::getAllAirlineInfo('NA');
     }
     if (count($aircraft_array) == 0) {
         $aircraft_array = Spotter::getAllAircraftInfo('NA');
     }
     if (count($departure_airport_array) == 0) {
         $departure_airport_array = Spotter::getAllAirportInfo('NA');
     }
     if (count($arrival_airport_array) == 0) {
         $arrival_airport_array = Spotter::getAllAirportInfo('NA');
     }
     if ($registration == '') {
         $registration = 'NA';
     }
     $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name) \n                VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name)";
     $airline_name = $airline_array[0]['name'];
     $airline_icao = $airline_array[0]['icao'];
     $airline_country = $airline_array[0]['country'];
     $airline_type = $airline_array[0]['type'];
     $aircraft_type = $aircraft_array[0]['type'];
     $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
     $departure_airport_name = $departure_airport_array[0]['name'];
     $departure_airport_city = $departure_airport_array[0]['city'];
     $departure_airport_country = $departure_airport_array[0]['country'];
     $arrival_airport_icao = $arrival_airport_icao;
     $arrival_airport_name = $arrival_airport_array[0]['name'];
     $arrival_airport_city = $arrival_airport_array[0]['city'];
     $arrival_airport_country = $arrival_airport_array[0]['country'];
     $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name);
     try {
         $Connection = new Connection();
         $sth = Connection::$db->prepare($query);
         $sth->execute($query_values);
         Connection::$db = null;
     } catch (PDOException $e) {
         return "error : " . $e->getMessage();
     }
     return "success";
 }
Exemplo n.º 4
0
 function add($line)
 {
     global $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug, $globalIVAO;
     /*
     	$Spotter = new Spotter();
     	$dbc = $Spotter->db;
     	$SpotterLive = new SpotterLive($dbc);
     	$Common = new Common();
     	$Schedule = new Schedule($dbc);
     */
     date_default_timezone_set('UTC');
     // signal handler - playing nice with sockets and dump1090
     // pcntl_signal_dispatch();
     // get the time (so we can figure the timeout)
     $time = time();
     //pcntl_signal_dispatch();
     $dataFound = false;
     $putinarchive = false;
     $send = false;
     // SBS format is CSV format
     if (is_array($line) && isset($line['hex'])) {
         //print_r($line);
         if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
             /*
             $dbc = $this->db;
             $Connection = new Connection($dbc);
             $Connection->connectionExists();
             $dbc = $Connection->db;
             */
             //$Spotter = new Spotter($dbc);
             //$SpotterLive = new SpotterLive($dbc);
             $Common = new Common();
             //		echo $this->nb++."\n";
             //$this->db = $dbc;
             $hex = trim($line['hex']);
             $id = trim($line['hex']);
             //print_r($this->all_flights);
             if (!isset($this->all_flights[$id]['hex'])) {
                 $this->all_flights[$id] = array('hex' => $hex);
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
                 if (preg_match('/^(\\d{4}(?:\\-\\d{2}){2} \\d{2}(?:\\:\\d{2}){2})$/', $line['datetime'])) {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
                 } else {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
                 }
                 if (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') {
                     $Spotter = new Spotter();
                     $aircraft_icao = $Spotter->getAllAircraftType($hex);
                     $Spotter->db = null;
                     if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
                         if ($line['aircraft_type'] == 'PARA_GLIDER') {
                             $aircraft_icao = 'GLID';
                         } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
                             $aircraft_icao = 'UHEL';
                         } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
                             $aircraft_icao = 'TOWPLANE';
                         } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
                             $aircraft_icao = 'POWAIRC';
                         }
                     }
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
                 } else {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
                 }
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'noarchive' => false));
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
                 if (!isset($line['id'])) {
                     if (!isset($globalDaemon)) {
                         $globalDaemon = TRUE;
                     }
                     //			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')));
                     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')));
                     }
                     //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
                 } else {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
                 }
                 if ($globalDebug) {
                     echo "*********** New aircraft hex : " . $hex . " ***********\n";
                 }
             }
             if (isset($line['datetime']) && $line['datetime'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
             }
             if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
             }
             if (isset($line['waypoints']) && $line['waypoints'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
             }
             if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
             }
             if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
             }
             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'])) {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
                 /*
                 		    if (!isset($line['id'])) {
                 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
                 //			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')));
                 			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')));
                 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
                 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
                 */
                 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']));
                 }
                 $putinarchive = true;
                 if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
                     $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' => ''));
                 } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
                     $Spotter = new Spotter();
                     $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
                     $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
                     $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' => ''));
                 } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
                     $Spotter = new Spotter();
                     $route = $Spotter->getRouteInfo(trim($line['ident']));
                     $Spotter->db = null;
                     if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
                         //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
                         if ($route['fromairport_icao'] != $route['toairport_icao']) {
                             //    $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']));
                             $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']));
                         }
                     }
                     if (!isset($globalFork)) {
                         $globalFork = TRUE;
                     }
                     if (function_exists('pcntl_fork') && $globalFork && !$globalIVAO) {
                         $this->nb++;
                         $pids[$id] = pcntl_fork();
                         if (!$pids[$id]) {
                             $sid = posix_setsid();
                             $this->get_Schedule($id, trim($line['ident']));
                             exit(0);
                         }
                     }
                 }
             }
             if (isset($line['speed']) && $line['speed'] != '') {
                 //    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
                 //$dataFound = true;
             } 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()) {
                     $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
                     if ($distance > 1000 && $distance < 10000) {
                         // use datetime
                         $speed = $distance / (time() - $this->all_flights[$id]['time_last_coord']);
                         $speed = $speed * 3.6;
                         if ($speed < 1000) {
                             $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
                         }
                         if ($globalDebug) {
                             echo "ø Calculated Speed for " . $this->all_flights[$id]['hex'] . " : " . $speed . " - distance : " . $distance . "\n";
                         }
                     }
                 }
             }
             if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
                 if (!isset($this->all_flights[$id]['time_last_coord']) || $Common->withinThreshold(time() - $this->all_flights[$id]['time_last_coord'], $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']))) {
                     if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
                         //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) {
                         if (!isset($this->all_flights[$id]['archive_latitude'])) {
                             $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
                         }
                         if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.02) {
                             $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
                             $dataFound = true;
                             $this->all_flights[$id]['time_last_coord'] = time();
                         }
                         // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                         $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
                         if (abs($this->all_flights[$id]['archive_latitude'] - $this->all_flights[$id]['latitude']) > 0.3) {
                             $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
                             $putinarchive = true;
                         }
                         /*
                         } elseif (isset($this->all_flights[$id]['latitude'])) {
                         				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
                         }
                         */
                     }
                     if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
                         if ($line['longitude'] > 180) {
                             $line['longitude'] = $line['longitude'] - 360;
                         }
                         //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) {
                         if (!isset($this->all_flights[$id]['archive_longitude'])) {
                             $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
                         }
                         if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.02) {
                             $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
                             $dataFound = true;
                             $this->all_flights[$id]['time_last_coord'] = time();
                         }
                         // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                         $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
                         if (abs($this->all_flights[$id]['archive_longitude'] - $this->all_flights[$id]['longitude']) > 0.3) {
                             $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
                             $putinarchive = true;
                         }
                         /*
                         } elseif (isset($this->all_flights[$id]['longitude'])) {
                         				if ($globalDebug) echo '!!! Strange longitude value - diff : '.abs($this->all_flights[$id]['longitude']-$line['longitude']).'- previous lat : '.$this->all_flights[$id]['longitude'].'- new lat : '.$line['longitude']."\n";
                         }
                         */
                     }
                 } else {
                     if ($globalDebug) {
                         echo '!!! Too much distance in short time... for ' . $this->all_flights[$id]['ident'] . "\n";
                     }
                 }
             }
             if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
                 //$dataFound = true;
             }
             if (isset($line['emergency']) && $line['emergency'] != '') {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
                 //$dataFound = true;
             }
             if (isset($line['ground']) && $line['ground'] != '') {
                 if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
                     // Here we force archive of flight because after ground it's a new one (or should be)
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
                     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')));
                     } elseif (isset($line['id'])) {
                         $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
                     } 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']));
                     }
                 }
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
                 //$dataFound = true;
             }
             if (isset($line['squawk']) && $line['squawk'] != '') {
                 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'])) {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
                     $highlight = '';
                     if ($this->all_flights[$id]['squawk'] == '7500') {
                         $highlight = 'Squawk 7500 : Hijack at ' . date('Y-m-d G:i') . ' UTC';
                     }
                     if ($this->all_flights[$id]['squawk'] == '7600') {
                         $highlight = 'Squawk 7600 : Lost Comm (radio failure) at ' . date('Y-m-d G:i') . ' UTC';
                     }
                     if ($this->all_flights[$id]['squawk'] == '7700') {
                         $highlight = 'Squawk 7700 : Emergency at ' . date('Y-m-d G:i') . ' UTC';
                     }
                     if ($highlight != '') {
                         $Spotter = new Spotter();
                         $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
                         $Spotter->db = null;
                         $putinarchive = true;
                         $highlight = '';
                     }
                 } else {
                     $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
                 }
                 //$dataFound = true;
             }
             if (isset($line['altitude']) && $line['altitude'] != '') {
                 //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
                 if (abs(round($line['altitude'] / 100) - $this->all_flights[$id]['altitude']) > 2) {
                     $putinarchive = true;
                 }
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude'] / 100)));
                 //$dataFound = true;
                 //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
             }
             if (isset($line['noarchive']) && $line['noarchive'] == true) {
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
             }
             if (isset($line['heading']) && $line['heading'] != '') {
                 if (abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) {
                     $putinarchive = true;
                 }
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
                 //$dataFound = true;
             } 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']) {
                 $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']);
                 $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
                 if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) {
                     $putinarchive = true;
                 }
                 if ($globalDebug) {
                     echo "ø Calculated Heading for " . $this->all_flights[$id]['hex'] . " : " . $heading . "\n";
                 }
             }
             if (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
                 $dataFound = false;
             }
             //		print_r($this->all_flights[$id]);
             //gets the callsign from the last hour
             //if (time()-$this->all_flights[$id]['lastupdate'] > 30 && $dataFound == true && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
             //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
             if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
                 $this->all_flights[$id]['lastupdate'] = time();
                 if ($this->all_flights[$id]['addedSpotter'] == 0) {
                     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']) {
                         //print_r($this->all_flights);
                         //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
                         //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
                         if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
                             if ($globalDebug) {
                                 echo "Check if aircraft is already in DB...";
                             }
                             $SpotterLive = new SpotterLive();
                             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')) {
                                 $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
                             } else {
                                 $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
                             }
                             $SpotterLive->db = null;
                             if ($globalDebug && $recent_ident == '') {
                                 echo " Not in DB.\n";
                             } elseif ($globalDebug && $recent_ident != '') {
                                 echo " Already in DB.\n";
                             }
                         } else {
                             $recent_ident = '';
                             $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
                         }
                         //if there was no aircraft with the same callsign within the last hour and go post it into the archive
                         if ($recent_ident == "") {
                             if ($globalDebug) {
                                 echo "\\o/ Add " . $this->all_flights[$id]['ident'] . " in archive DB : ";
                             }
                             if ($this->all_flights[$id]['departure_airport'] == "") {
                                 $this->all_flights[$id]['departure_airport'] = "NA";
                             }
                             if ($this->all_flights[$id]['arrival_airport'] == "") {
                                 $this->all_flights[$id]['arrival_airport'] = "NA";
                             }
                             //adds the spotter data for the archive
                             $ignoreImport = false;
                             foreach ($globalAirportIgnore as $airportIgnore) {
                                 if ($this->all_flights[$id]['departure_airport'] != $airportIgnore && $this->all_flights[$id]['arrival_airport'] != $airportIgnore) {
                                     $ignoreImport = true;
                                 }
                             }
                             if (!$ignoreImport) {
                                 $highlight = '';
                                 if ($this->all_flights[$id]['squawk'] == '7500') {
                                     $highlight = 'Squawk 7500 : Hijack';
                                 }
                                 if ($this->all_flights[$id]['squawk'] == '7600') {
                                     $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
                                 }
                                 if ($this->all_flights[$id]['squawk'] == '7700') {
                                     $highlight = 'Squawk 7700 : Emergency';
                                 }
                                 $Spotter = new Spotter();
                                 $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]['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']);
                                 $Spotter->db = null;
                             }
                             $ignoreImport = false;
                             $this->all_flights[$id]['addedSpotter'] = 1;
                             //print_r($this->all_flights[$id]);
                             if ($globalDebug) {
                                 echo $result . "\n";
                             }
                             /*
                             if (isset($globalArchive) && $globalArchive) {
                                 $archives_ident = SpotterLive->getAllLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
                                 foreach ($archives_ident as $archive) {
                             	SpotterArchive->addSpotterArchiveData($archive['flightaware_id'], $archive['ident'], $archive['registration'],$archive['airline_name'],$archive['airline_icao'],$archive['airline_country'],$archive['airline_type'],$archive['aircraft_icao'],$archive['aircraft_shadow'],$archive['aircraft_name'],$archive['aircraft_manufacturer'], $archive['departure_airport_icao'],$archive['departure_airport_name'],$archive['departure_airport_city'],$archive['departure_airport_country'],$archive['departure_airport_time'],
                             	$archive['arrival_airport_icao'],$archive['arrival_airport_name'],$archive['arrival_airport_city'],$archive['arrival_airport_country'],$archive['arrival_airport_time'],
                             	$archive['route_stop'],$archive['date'],$archive['latitude'], $archive['longitude'], $archive['waypoints'], $archive['altitude'], $archive['heading'], $archive['ground_speed'],
                             	$archive['squawk'],$archive['ModeS']);
                                 }
                             }
                             */
                             //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
                             if ($this->last_delete == '' || time() - $this->last_delete > 1800) {
                                 if ($globalDebug) {
                                     echo "---- Deleting Live Spotter data older than 9 hours...";
                                 }
                                 //SpotterLive->deleteLiveSpotterDataNotUpdated();
                                 $SpotterLive = new SpotterLive();
                                 $SpotterLive->deleteLiveSpotterData();
                                 $SpotterLive->db = null;
                                 if ($globalDebug) {
                                     echo " Done\n";
                                 }
                                 $this->last_delete = time();
                             }
                         } else {
                             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')) {
                                 $this->all_flights[$id]['id'] = $recent_ident;
                                 $this->all_flights[$id]['addedSpotter'] = 1;
                             }
                         }
                     }
                 }
                 //adds the spotter LIVE data
                 //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
                 //echo "\nAdd in Live !! \n";
                 //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
                 if ($globalDebug) {
                     echo 'DATA : hex : ' . $this->all_flights[$id]['hex'] . ' - ident : ' . $this->all_flights[$id]['ident'] . ' - ICAO : ' . $this->all_flights[$id]['aircraft_icao'] . ' - Departure Airport : ' . $this->all_flights[$id]['departure_airport'] . ' - Arrival Airport : ' . $this->all_flights[$id]['arrival_airport'] . ' - Latitude : ' . $this->all_flights[$id]['latitude'] . ' - Longitude : ' . $this->all_flights[$id]['longitude'] . ' - waypoints : ' . $this->all_flights[$id]['waypoints'] . ' - Altitude : ' . $this->all_flights[$id]['altitude'] . ' - Heading : ' . $this->all_flights[$id]['heading'] . ' - Speed : ' . $this->all_flights[$id]['speed'] . ' - Departure Airport Time : ' . $this->all_flights[$id]['departure_airport_time'] . ' - Arrival Airport time : ' . $this->all_flights[$id]['arrival_airport_time'] . "\n";
                 }
                 $ignoreImport = false;
                 if ($this->all_flights[$id]['departure_airport'] == "") {
                     $this->all_flights[$id]['departure_airport'] = "NA";
                 }
                 if ($this->all_flights[$id]['arrival_airport'] == "") {
                     $this->all_flights[$id]['arrival_airport'] = "NA";
                 }
                 foreach ($globalAirportIgnore as $airportIgnore) {
                     if ($this->all_flights[$id]['departure_airport'] != $airportIgnore && $this->all_flights[$id]['arrival_airport'] != $airportIgnore) {
                         $ignoreImport = true;
                     }
                 }
                 if (!$ignoreImport) {
                     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']) {
                         if ($globalDebug) {
                             echo "\\o/ Add " . $this->all_flights[$id]['ident'] . " in Live DB : ";
                         }
                         $SpotterLive = new SpotterLive();
                         $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]['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'], $putinarchive, $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['noarchive']);
                         $SpotterLive->db = null;
                         $this->all_flights[$id]['lastupdate'] = time();
                         if ($putinarchive) {
                             $send = true;
                         }
                         //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
                         if ($globalDebug) {
                             echo $result . "\n";
                         }
                     } 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";
                     }
                     $this->del();
                     if ($this->last_delete_hourly == '' || time() - $this->last_delete_hourly > 900) {
                         if ($globalDebug) {
                             echo "---- Deleting Live Spotter data Not updated since 1 hour...";
                         }
                         $SpotterLive = new SpotterLive();
                         $SpotterLive->deleteLiveSpotterDataNotUpdated();
                         $SpotterLive->db = null;
                         //SpotterLive->deleteLiveSpotterData();
                         if ($globalDebug) {
                             echo " Done\n";
                         }
                         $this->last_delete_hourly = time();
                     }
                 }
                 $ignoreImport = false;
             }
             if (function_exists('pcntl_fork') && $globalFork) {
                 pcntl_signal(SIGCHLD, SIG_IGN);
             }
             if ($send) {
                 return $this->all_flights[$id];
             }
         }
     }
 }