@@ -16,20 +16,20 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 17 | 17 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
| 18 | 18 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 19 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | class SpotterImport { |
| 23 | - private $all_flights = array(); |
|
| 24 | - private $last_delete_hourly = 0; |
|
| 25 | - private $last_delete = 0; |
|
| 26 | - private $stats = array(); |
|
| 27 | - private $tmd = 0; |
|
| 28 | - private $source_location = array(); |
|
| 29 | - public $db = null; |
|
| 30 | - public $nb = 0; |
|
| 23 | + private $all_flights = array(); |
|
| 24 | + private $last_delete_hourly = 0; |
|
| 25 | + private $last_delete = 0; |
|
| 26 | + private $stats = array(); |
|
| 27 | + private $tmd = 0; |
|
| 28 | + private $source_location = array(); |
|
| 29 | + public $db = null; |
|
| 30 | + public $nb = 0; |
|
| 31 | 31 | |
| 32 | - public function __construct($dbc = null) { |
|
| 32 | + public function __construct($dbc = null) { |
|
| 33 | 33 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
| 34 | 34 | if (!(isset($globalNoDB) && $globalNoDB)) { |
| 35 | 35 | $Connection = new Connection($dbc); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | $currentdate = date('Y-m-d'); |
| 42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 43 | 43 | if (!empty($sourcestat)) { |
| 44 | - foreach($sourcestat as $srcst) { |
|
| 45 | - $type = $srcst['stats_type']; |
|
| 44 | + foreach($sourcestat as $srcst) { |
|
| 45 | + $type = $srcst['stats_type']; |
|
| 46 | 46 | if ($type == 'polar' || $type == 'hist') { |
| 47 | - $source = $srcst['source_name']; |
|
| 48 | - $data = $srcst['source_data']; |
|
| 49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 50 | - } |
|
| 51 | - } |
|
| 47 | + $source = $srcst['source_name']; |
|
| 48 | + $data = $srcst['source_data']; |
|
| 49 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | $GeoidClass = FALSE; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function get_Schedule($id,$ident) { |
|
| 68 | + public function get_Schedule($id,$ident) { |
|
| 69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 70 | 70 | // Get schedule here, so it's done only one time |
| 71 | 71 | |
@@ -85,43 +85,43 @@ discard block |
||
| 85 | 85 | $operator = $Spotter->getOperator($ident); |
| 86 | 86 | $scheduleexist = false; |
| 87 | 87 | if ($Schedule->checkSchedule($operator) == 0) { |
| 88 | - $operator = $Translation->checkTranslation($ident); |
|
| 89 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 88 | + $operator = $Translation->checkTranslation($ident); |
|
| 89 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
| 91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 95 | - // Should also check if route schedule = route from DB |
|
| 96 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 92 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 95 | + // Should also check if route schedule = route from DB |
|
| 96 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 98 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 99 | - if (trim($airport_icao) != '') { |
|
| 98 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 99 | + if (trim($airport_icao) != '') { |
|
| 100 | 100 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 101 | 101 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 102 | - } |
|
| 102 | + } |
|
| 103 | + } |
|
| 103 | 104 | } |
| 104 | - } |
|
| 105 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 105 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 106 | 106 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 107 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 108 | - if (trim($airport_icao) != '') { |
|
| 107 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 108 | + if (trim($airport_icao) != '') { |
|
| 109 | 109 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 110 | 110 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | - } |
|
| 114 | - $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']); |
|
| 113 | + } |
|
| 114 | + $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']); |
|
| 115 | 115 | } |
| 116 | - } else $scheduleexist = true; |
|
| 116 | + } else $scheduleexist = true; |
|
| 117 | 117 | } else $scheduleexist = true; |
| 118 | 118 | // close connection, at least one way will work ? |
| 119 | - if ($scheduleexist) { |
|
| 119 | + if ($scheduleexist) { |
|
| 120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 121 | - $sch = $Schedule->getSchedule($operator); |
|
| 121 | + $sch = $Schedule->getSchedule($operator); |
|
| 122 | 122 | $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'])); |
| 123 | 123 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | $Spotter->db = null; |
| 126 | 126 | $Schedule->db = null; |
| 127 | 127 | $Translation->db = null; |
@@ -136,65 +136,65 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | */ |
| 138 | 138 | } |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - public function checkAll() { |
|
| 141 | + public function checkAll() { |
|
| 142 | 142 | global $globalDebug, $globalNoImport; |
| 143 | 143 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 144 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 145 | - foreach ($this->all_flights as $key => $flight) { |
|
| 145 | + foreach ($this->all_flights as $key => $flight) { |
|
| 146 | 146 | if (isset($this->all_flights[$key]['id'])) { |
| 147 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 148 | - $Spotter = new Spotter($this->db); |
|
| 149 | - $real_arrival = $this->arrival($key); |
|
| 150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
| 151 | - } |
|
| 152 | - } |
|
| 147 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 148 | + $Spotter = new Spotter($this->db); |
|
| 149 | + $real_arrival = $this->arrival($key); |
|
| 150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | - } |
|
| 155 | 155 | |
| 156 | - public function arrival($key) { |
|
| 156 | + public function arrival($key) { |
|
| 157 | 157 | global $globalClosestMinDist, $globalDebug; |
| 158 | 158 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 159 | 159 | $Spotter = new Spotter($this->db); |
| 160 | - $airport_icao = ''; |
|
| 161 | - $airport_time = ''; |
|
| 162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 160 | + $airport_icao = ''; |
|
| 161 | + $airport_time = ''; |
|
| 162 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 165 | - if (isset($closestAirports[0])) { |
|
| 166 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 167 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 168 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 170 | - } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 171 | - foreach ($closestAirports as $airport) { |
|
| 172 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 173 | - $airport_icao = $airport['icao']; |
|
| 174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 176 | - break; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - } 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))) { |
|
| 180 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 181 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 182 | - } else { |
|
| 183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 184 | - } |
|
| 185 | - } else { |
|
| 186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 187 | - } |
|
| 164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 165 | + if (isset($closestAirports[0])) { |
|
| 166 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 167 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 168 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 169 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 170 | + } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 171 | + foreach ($closestAirports as $airport) { |
|
| 172 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 173 | + $airport_icao = $airport['icao']; |
|
| 174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 176 | + break; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + } 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))) { |
|
| 180 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 181 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 182 | + } else { |
|
| 183 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 184 | + } |
|
| 185 | + } else { |
|
| 186 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - } else { |
|
| 190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 191 | - } |
|
| 192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 193 | - } |
|
| 189 | + } else { |
|
| 190 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 191 | + } |
|
| 192 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | |
| 197 | - public function del() { |
|
| 197 | + public function del() { |
|
| 198 | 198 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 199 | 199 | // Delete old infos |
| 200 | 200 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - public function delKey($key) { |
|
| 211 | + public function delKey($key) { |
|
| 212 | 212 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 213 | 213 | // Delete old infos |
| 214 | 214 | if (isset($this->all_flights[$key]['id'])) { |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | if ($globalDebug) echo "\n"; |
| 231 | 231 | } |
| 232 | 232 | unset($this->all_flights[$key]); |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - public function add($line) { |
|
| 235 | + public function add($line) { |
|
| 236 | 236 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive, $globalAPRSdelete; |
| 237 | 237 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 238 | 238 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -258,20 +258,20 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | // SBS format is CSV format |
| 260 | 260 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 261 | - //print_r($line); |
|
| 262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 261 | + //print_r($line); |
|
| 262 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 264 | 264 | |
| 265 | 265 | // Increment message number |
| 266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 267 | - $current_date = date('Y-m-d'); |
|
| 268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | - else $source = ''; |
|
| 270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 271 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 272 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 273 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 267 | + $current_date = date('Y-m-d'); |
|
| 268 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | + else $source = ''; |
|
| 270 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 271 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 272 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 273 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 274 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /* |
@@ -287,54 +287,54 @@ discard block |
||
| 287 | 287 | //$this->db = $dbc; |
| 288 | 288 | |
| 289 | 289 | //$hex = trim($line['hex']); |
| 290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | - else $id = trim($line['id']); |
|
| 290 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | + else $id = trim($line['id']); |
|
| 292 | 292 | |
| 293 | 293 | if (!isset($this->all_flights[$id])) { |
| 294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 295 | - $this->all_flights[$id] = array(); |
|
| 296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
| 298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 299 | - if (!isset($line['id'])) { |
|
| 294 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
| 295 | + $this->all_flights[$id] = array(); |
|
| 296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
| 298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 299 | + if (!isset($line['id'])) { |
|
| 300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 301 | 301 | // 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'))); |
| 302 | 302 | // 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'))); |
| 303 | 303 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 304 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 304 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 307 | 307 | } |
| 308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | //print_r($this->all_flights); |
| 313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 315 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 315 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 317 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 318 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 317 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 318 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 319 | 319 | $timeelapsed = microtime(true); |
| 320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 321 | - $Spotter = new Spotter($this->db); |
|
| 322 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
| 321 | + $Spotter = new Spotter($this->db); |
|
| 322 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
| 323 | 323 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
| 324 | - } else { |
|
| 324 | + } else { |
|
| 325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 326 | - } |
|
| 327 | - $Spotter->db = null; |
|
| 328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 326 | + } |
|
| 327 | + $Spotter->db = null; |
|
| 328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 330 | 330 | } |
| 331 | - } |
|
| 332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 331 | + } |
|
| 332 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 334 | 334 | } |
| 335 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
| 336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 337 | - } |
|
| 335 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
| 336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 337 | + } |
|
| 338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 339 | 339 | $icao = $line['aircraft_icao']; |
| 340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 366 | 366 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 367 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 367 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 368 | 368 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 369 | - } else { |
|
| 369 | + } else { |
|
| 370 | 370 | 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"; |
| 371 | 371 | 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"; |
| 372 | 372 | /* |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | print_r($line); |
| 376 | 376 | */ |
| 377 | 377 | return ''; |
| 378 | - } |
|
| 378 | + } |
|
| 379 | 379 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 381 | 381 | return ''; |
@@ -391,21 +391,21 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 395 | 395 | } |
| 396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 398 | 398 | } |
| 399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 401 | 401 | } |
| 402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 407 | 407 | |
| 408 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 408 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 411 | 411 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -414,23 +414,23 @@ discard block |
||
| 414 | 414 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 415 | 415 | 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'])); |
| 416 | 416 | } else { |
| 417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 418 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 418 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 419 | 419 | $timeelapsed = microtime(true); |
| 420 | - $Spotter = new Spotter($this->db); |
|
| 421 | - $fromsource = NULL; |
|
| 422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 420 | + $Spotter = new Spotter($this->db); |
|
| 421 | + $fromsource = NULL; |
|
| 422 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
| 427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
| 428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 429 | 429 | $Spotter->db = null; |
| 430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 431 | - } |
|
| 431 | + } |
|
| 432 | 432 | } |
| 433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 434 | 434 | |
| 435 | 435 | /* |
| 436 | 436 | if (!isset($line['id'])) { |
@@ -440,63 +440,63 @@ discard block |
||
| 440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 442 | 442 | */ |
| 443 | - 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'])); |
|
| 443 | + 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'])); |
|
| 444 | 444 | |
| 445 | - //$putinarchive = true; |
|
| 446 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 445 | + //$putinarchive = true; |
|
| 446 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 447 | 447 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 448 | - } |
|
| 449 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 448 | + } |
|
| 449 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 450 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 451 | - } |
|
| 452 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 453 | - $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' => '')); |
|
| 454 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 451 | + } |
|
| 452 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 453 | + $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' => '')); |
|
| 454 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 455 | 455 | $timeelapsed = microtime(true); |
| 456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 457 | 457 | $Spotter = new Spotter($this->db); |
| 458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 460 | - $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' => '')); |
|
| 460 | + $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' => '')); |
|
| 461 | 461 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 462 | - } |
|
| 463 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 462 | + } |
|
| 463 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 464 | 464 | $timeelapsed = microtime(true); |
| 465 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 466 | - $Spotter = new Spotter($this->db); |
|
| 467 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 468 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 466 | + $Spotter = new Spotter($this->db); |
|
| 467 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 468 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 469 | 469 | $Translation = new Translation($this->db); |
| 470 | 470 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
| 471 | 471 | $route = $Spotter->getRouteInfo($ident); |
| 472 | 472 | $Translation->db = null; |
| 473 | - } |
|
| 474 | - $Spotter->db = null; |
|
| 475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 476 | - } |
|
| 473 | + } |
|
| 474 | + $Spotter->db = null; |
|
| 475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 476 | + } |
|
| 477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 478 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 479 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 478 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 479 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 480 | 480 | // $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'])); |
| 481 | - $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'])); |
|
| 482 | - } |
|
| 481 | + $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'])); |
|
| 482 | + } |
|
| 483 | 483 | } |
| 484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
| 485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 486 | 486 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 487 | 487 | } |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 495 | - //$dataFound = true; |
|
| 493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 495 | + //$dataFound = true; |
|
| 496 | 496 | } 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'])) { |
| 497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 498 | - if ($distance > 1000 && $distance < 10000) { |
|
| 499 | - // use datetime |
|
| 497 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 498 | + if ($distance > 1000 && $distance < 10000) { |
|
| 499 | + // use datetime |
|
| 500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 501 | 501 | $speed = $speed*3.6; |
| 502 | 502 | if ($speed < 1000) { |
@@ -505,49 +505,49 @@ discard block |
||
| 505 | 505 | } else { |
| 506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 507 | 507 | } |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | |
| 512 | 512 | |
| 513 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 514 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 516 | - return false; |
|
| 517 | - } |
|
| 518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | - else unset($timediff); |
|
| 520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | - else unset($timediff_archive); |
|
| 522 | - if ($this->tmd > 5 |
|
| 523 | - || (isset($line['format_source']) |
|
| 524 | - && $line['format_source'] == 'airwhere' |
|
| 525 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
| 526 | - || !isset($this->all_flights[$id]['longitude'])) |
|
| 527 | - || (isset($this->all_flights[$id]['latitude']) |
|
| 528 | - && isset($this->all_flights[$id]['longitude']) |
|
| 529 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 530 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 531 | - ) |
|
| 532 | - ) |
|
| 533 | - ) |
|
| 534 | - || (isset($globalVA) && $globalVA) |
|
| 535 | - || (isset($globalIVAO) && $globalIVAO) |
|
| 536 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
| 537 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
| 538 | - || (isset($globalVAM) && $globalVAM) |
|
| 539 | - || !isset($timediff) |
|
| 540 | - || (isset($timediff) && $timediff > $globalLiveInterval) |
|
| 541 | - || $globalArchive |
|
| 542 | - || (isset($timediff) && $timediff > 30 |
|
| 543 | - && isset($this->all_flights[$id]['latitude']) |
|
| 544 | - && isset($this->all_flights[$id]['longitude']) |
|
| 545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 546 | - ) |
|
| 547 | - ) { |
|
| 513 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 514 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 515 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 516 | + return false; |
|
| 517 | + } |
|
| 518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | + else unset($timediff); |
|
| 520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | + else unset($timediff_archive); |
|
| 522 | + if ($this->tmd > 5 |
|
| 523 | + || (isset($line['format_source']) |
|
| 524 | + && $line['format_source'] == 'airwhere' |
|
| 525 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
| 526 | + || !isset($this->all_flights[$id]['longitude'])) |
|
| 527 | + || (isset($this->all_flights[$id]['latitude']) |
|
| 528 | + && isset($this->all_flights[$id]['longitude']) |
|
| 529 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 530 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 531 | + ) |
|
| 532 | + ) |
|
| 533 | + ) |
|
| 534 | + || (isset($globalVA) && $globalVA) |
|
| 535 | + || (isset($globalIVAO) && $globalIVAO) |
|
| 536 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
| 537 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
| 538 | + || (isset($globalVAM) && $globalVAM) |
|
| 539 | + || !isset($timediff) |
|
| 540 | + || (isset($timediff) && $timediff > $globalLiveInterval) |
|
| 541 | + || $globalArchive |
|
| 542 | + || (isset($timediff) && $timediff > 30 |
|
| 543 | + && isset($this->all_flights[$id]['latitude']) |
|
| 544 | + && isset($this->all_flights[$id]['longitude']) |
|
| 545 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 546 | + ) |
|
| 547 | + ) { |
|
| 548 | 548 | |
| 549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (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']))) { |
| 550 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 550 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 552 | 552 | || !$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'])) { |
| 553 | 553 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | $this->tmd = 0; |
| 561 | 561 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 562 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 563 | - $timeelapsed = microtime(true); |
|
| 564 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 562 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 563 | + $timeelapsed = microtime(true); |
|
| 564 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 565 | 565 | $Spotter = new Spotter($this->db); |
| 566 | 566 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 567 | 567 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | $Spotter->db = null; |
| 570 | 570 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 571 | 571 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
| 575 | - } |
|
| 576 | - /* |
|
| 575 | + } |
|
| 576 | + /* |
|
| 577 | 577 | else { |
| 578 | 578 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
| 579 | 579 | else { |
@@ -587,16 +587,16 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 590 | - //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) { |
|
| 590 | + //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) { |
|
| 591 | 591 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
| 592 | 592 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 593 | 593 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 594 | 594 | } |
| 595 | 595 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 596 | 596 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 597 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 598 | - $dataFound = true; |
|
| 599 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 597 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 598 | + $dataFound = true; |
|
| 599 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 600 | 600 | } |
| 601 | 601 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 602 | 602 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -607,25 +607,25 @@ discard block |
||
| 607 | 607 | //$putinarchive = true; |
| 608 | 608 | } |
| 609 | 609 | */ |
| 610 | - /* |
|
| 610 | + /* |
|
| 611 | 611 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 612 | 612 | 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"; |
| 613 | 613 | } |
| 614 | 614 | */ |
| 615 | 615 | } |
| 616 | 616 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 617 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 618 | - //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) { |
|
| 617 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 618 | + //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) { |
|
| 619 | 619 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 620 | 620 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 621 | 621 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 622 | 622 | } |
| 623 | 623 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 624 | 624 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 625 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 626 | - $dataFound = true; |
|
| 627 | - $this->all_flights[$id]['coordinates'] += 1; |
|
| 628 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 625 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 626 | + $dataFound = true; |
|
| 627 | + $this->all_flights[$id]['coordinates'] += 1; |
|
| 628 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 629 | 629 | } |
| 630 | 630 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 631 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -643,76 +643,76 @@ discard block |
||
| 643 | 643 | */ |
| 644 | 644 | } |
| 645 | 645 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
| 646 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 647 | - unset($updateinitial); |
|
| 648 | - $SpotterArchive = new SpotterArchive(); |
|
| 649 | - $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
| 650 | - $SpotterArchive->db = null; |
|
| 651 | - $Spotter = new Spotter(); |
|
| 652 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
| 653 | - $Spotter->db = null; |
|
| 646 | + if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 647 | + unset($updateinitial); |
|
| 648 | + $SpotterArchive = new SpotterArchive(); |
|
| 649 | + $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
| 650 | + $SpotterArchive->db = null; |
|
| 651 | + $Spotter = new Spotter(); |
|
| 652 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
| 653 | + $Spotter->db = null; |
|
| 654 | 654 | } |
| 655 | - } else if ($globalDebug && $timediff > 30) { |
|
| 655 | + } else if ($globalDebug && $timediff > 30) { |
|
| 656 | 656 | $this->tmd = $this->tmd + 1; |
| 657 | 657 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 658 | 658 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 659 | 659 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 660 | 660 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 661 | - } |
|
| 661 | + } |
|
| 662 | 662 | } |
| 663 | 663 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 664 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 664 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 666 | 666 | } |
| 667 | 667 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 669 | - //$dataFound = true; |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 669 | + //$dataFound = true; |
|
| 670 | 670 | } |
| 671 | 671 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 673 | 673 | } |
| 674 | 674 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 676 | 676 | } |
| 677 | 677 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 679 | - //$dataFound = true; |
|
| 678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 679 | + //$dataFound = true; |
|
| 680 | 680 | } |
| 681 | 681 | if (isset($line['ground']) && $line['ground'] != '') { |
| 682 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 682 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 683 | 683 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 684 | 684 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 685 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 686 | 686 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 687 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 688 | 688 | 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'])); |
| 689 | - } |
|
| 690 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 692 | - //$dataFound = true; |
|
| 689 | + } |
|
| 690 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 692 | + //$dataFound = true; |
|
| 693 | 693 | } |
| 694 | 694 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 695 | - 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'])) { |
|
| 696 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 698 | - $highlight = ''; |
|
| 699 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 702 | - if ($highlight != '') { |
|
| 695 | + 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'])) { |
|
| 696 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 698 | + $highlight = ''; |
|
| 699 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 702 | + if ($highlight != '') { |
|
| 703 | 703 | $timeelapsed = microtime(true); |
| 704 | 704 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 705 | - $Spotter = new Spotter($this->db); |
|
| 706 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 707 | - $Spotter->db = null; |
|
| 708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 705 | + $Spotter = new Spotter($this->db); |
|
| 706 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 707 | + $Spotter->db = null; |
|
| 708 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 709 | 709 | } |
| 710 | 710 | //$putinarchive = true; |
| 711 | 711 | //$highlight = ''; |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 715 | - //$dataFound = true; |
|
| 714 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 715 | + //$dataFound = true; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | $line['altitude'] = $line['altitude'] - $geoid; |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 726 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 727 | 727 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 728 | 728 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 729 | 729 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 730 | 730 | //$dataFound = true; |
| 731 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 732 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 731 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 732 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 733 | 733 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 734 | 734 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 735 | 735 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -738,27 +738,27 @@ discard block |
||
| 738 | 738 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 739 | 739 | 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'])); |
| 740 | 740 | } |
| 741 | - } |
|
| 742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 741 | + } |
|
| 742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 746 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 746 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | if (isset($line['heading']) && $line['heading'] != '') { |
| 750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 752 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 753 | - //$dataFound = true; |
|
| 750 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 752 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 753 | + //$dataFound = true; |
|
| 754 | 754 | } 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']) { |
| 755 | - $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']); |
|
| 756 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 755 | + $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']); |
|
| 756 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 757 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 759 | 759 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 760 | - // If not enough messages and ACARS set heading to 0 |
|
| 761 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 760 | + // If not enough messages and ACARS set heading to 0 |
|
| 761 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 762 | 762 | } |
| 763 | 763 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 764 | 764 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -771,133 +771,133 @@ discard block |
||
| 771 | 771 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 772 | 772 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 773 | 773 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 774 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 775 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 776 | - 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'])) { |
|
| 777 | - //print_r($this->all_flights); |
|
| 778 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 779 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 780 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 774 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 775 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 776 | + 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'])) { |
|
| 777 | + //print_r($this->all_flights); |
|
| 778 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 779 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 780 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 781 | 781 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 782 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 783 | - $timeelapsed = microtime(true); |
|
| 784 | - $SpotterLive = new SpotterLive($this->db); |
|
| 785 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 782 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 783 | + $timeelapsed = microtime(true); |
|
| 784 | + $SpotterLive = new SpotterLive($this->db); |
|
| 785 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 786 | 786 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 787 | 787 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 788 | - } elseif (isset($line['id'])) { |
|
| 788 | + } elseif (isset($line['id'])) { |
|
| 789 | 789 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 790 | 790 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 791 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 791 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 792 | 792 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 793 | 793 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 794 | - } else $recent_ident = ''; |
|
| 795 | - $SpotterLive->db=null; |
|
| 796 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 794 | + } else $recent_ident = ''; |
|
| 795 | + $SpotterLive->db=null; |
|
| 796 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 798 | 798 | } else $recent_ident = ''; |
| 799 | - } else { |
|
| 799 | + } else { |
|
| 800 | 800 | $recent_ident = ''; |
| 801 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 802 | - } |
|
| 803 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 804 | - if($recent_ident == "") |
|
| 805 | - { |
|
| 802 | + } |
|
| 803 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 804 | + if($recent_ident == "") |
|
| 805 | + { |
|
| 806 | 806 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 807 | 807 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 808 | 808 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 809 | 809 | //adds the spotter data for the archive |
| 810 | 810 | $ignoreImport = false; |
| 811 | 811 | foreach($globalAirportIgnore as $airportIgnore) { |
| 812 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 812 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 813 | 813 | $ignoreImport = true; |
| 814 | - } |
|
| 814 | + } |
|
| 815 | 815 | } |
| 816 | 816 | if (count($globalAirportAccept) > 0) { |
| 817 | - $ignoreImport = true; |
|
| 818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 817 | + $ignoreImport = true; |
|
| 818 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 820 | - $ignoreImport = false; |
|
| 820 | + $ignoreImport = false; |
|
| 821 | + } |
|
| 821 | 822 | } |
| 822 | - } |
|
| 823 | 823 | } |
| 824 | 824 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 825 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 825 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 826 | 826 | 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)) { |
| 827 | - $ignoreImport = true; |
|
| 827 | + $ignoreImport = true; |
|
| 828 | + } |
|
| 828 | 829 | } |
| 829 | - } |
|
| 830 | 830 | } |
| 831 | 831 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 832 | - $ignoreImport = true; |
|
| 833 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 832 | + $ignoreImport = true; |
|
| 833 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 834 | 834 | 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)) { |
| 835 | - $ignoreImport = false; |
|
| 835 | + $ignoreImport = false; |
|
| 836 | + } |
|
| 836 | 837 | } |
| 837 | - } |
|
| 838 | 838 | } |
| 839 | 839 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 840 | - $ignoreImport = true; |
|
| 841 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 840 | + $ignoreImport = true; |
|
| 841 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 842 | 842 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 843 | - $ignoreImport = false; |
|
| 843 | + $ignoreImport = false; |
|
| 844 | + } |
|
| 844 | 845 | } |
| 845 | - } |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | if (!$ignoreImport) { |
| 849 | - $highlight = ''; |
|
| 850 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | - 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'))); |
|
| 854 | - $timeelapsed = microtime(true); |
|
| 855 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 849 | + $highlight = ''; |
|
| 850 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | + 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'))); |
|
| 854 | + $timeelapsed = microtime(true); |
|
| 855 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 857 | - $Spotter = new Spotter($this->db); |
|
| 858 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 859 | - $Spotter->db = null; |
|
| 860 | - if ($globalDebug) { |
|
| 857 | + $Spotter = new Spotter($this->db); |
|
| 858 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 859 | + $Spotter->db = null; |
|
| 860 | + if ($globalDebug) { |
|
| 861 | 861 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
| 862 | 862 | else echo 'Success'; |
| 863 | - } |
|
| 864 | - if (count($result) > 1) { |
|
| 865 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 863 | + } |
|
| 864 | + if (count($result) > 1) { |
|
| 865 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 866 | 866 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
| 867 | 867 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
| 868 | - } |
|
| 868 | + } |
|
| 869 | + } |
|
| 869 | 870 | } |
| 870 | - } |
|
| 871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 872 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 871 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 872 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 873 | 873 | |
| 874 | - // Add source stat in DB |
|
| 875 | - $Stats = new Stats($this->db); |
|
| 876 | - if (!empty($this->stats)) { |
|
| 874 | + // Add source stat in DB |
|
| 875 | + $Stats = new Stats($this->db); |
|
| 876 | + if (!empty($this->stats)) { |
|
| 877 | 877 | if ($globalDebug) echo 'Add source stats : '; |
| 878 | - foreach($this->stats as $date => $data) { |
|
| 879 | - foreach($data as $source => $sourced) { |
|
| 880 | - //print_r($sourced); |
|
| 881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 883 | - if (isset($sourced['msg'])) { |
|
| 884 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 885 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 886 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 887 | - unset($this->stats[$date][$source]['msg']); |
|
| 888 | - } |
|
| 889 | - } |
|
| 890 | - } |
|
| 891 | - if ($date != date('Y-m-d')) { |
|
| 892 | - unset($this->stats[$date]); |
|
| 893 | - } |
|
| 894 | - } |
|
| 895 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 878 | + foreach($this->stats as $date => $data) { |
|
| 879 | + foreach($data as $source => $sourced) { |
|
| 880 | + //print_r($sourced); |
|
| 881 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 883 | + if (isset($sourced['msg'])) { |
|
| 884 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 885 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 886 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 887 | + unset($this->stats[$date][$source]['msg']); |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | + if ($date != date('Y-m-d')) { |
|
| 892 | + unset($this->stats[$date]); |
|
| 893 | + } |
|
| 894 | + } |
|
| 895 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 896 | 896 | |
| 897 | - } |
|
| 898 | - $Stats->db = null; |
|
| 899 | - } |
|
| 900 | - $this->del(); |
|
| 897 | + } |
|
| 898 | + $Stats->db = null; |
|
| 899 | + } |
|
| 900 | + $this->del(); |
|
| 901 | 901 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 902 | 902 | //$ignoreImport = false; |
| 903 | 903 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -915,41 +915,41 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 917 | 917 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 918 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 919 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 920 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 918 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 919 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 920 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 921 | 921 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 922 | - $SpotterLive = new SpotterLive($this->db); |
|
| 923 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 924 | - $SpotterLive->db=null; |
|
| 922 | + $SpotterLive = new SpotterLive($this->db); |
|
| 923 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 924 | + $SpotterLive->db=null; |
|
| 925 | + } |
|
| 925 | 926 | } |
| 926 | - } |
|
| 927 | - if ($globalDebug) echo " Done\n"; |
|
| 928 | - $this->last_delete = time(); |
|
| 927 | + if ($globalDebug) echo " Done\n"; |
|
| 928 | + $this->last_delete = time(); |
|
| 929 | 929 | } |
| 930 | - } else { |
|
| 930 | + } else { |
|
| 931 | 931 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
| 932 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 933 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 932 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 933 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 934 | 934 | } |
| 935 | 935 | if (isset($globalDaemon) && !$globalDaemon) { |
| 936 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 936 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 937 | 937 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 938 | - $Spotter = new Spotter($this->db); |
|
| 939 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 940 | - $Spotter->db = null; |
|
| 938 | + $Spotter = new Spotter($this->db); |
|
| 939 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 940 | + $Spotter->db = null; |
|
| 941 | + } |
|
| 941 | 942 | } |
| 942 | - } |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - } |
|
| 945 | + } |
|
| 946 | 946 | } |
| 947 | - } |
|
| 948 | - //adds the spotter LIVE data |
|
| 949 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 950 | - //echo "\nAdd in Live !! \n"; |
|
| 951 | - //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"; |
|
| 952 | - if ($globalDebug) { |
|
| 947 | + } |
|
| 948 | + //adds the spotter LIVE data |
|
| 949 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 950 | + //echo "\nAdd in Live !! \n"; |
|
| 951 | + //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"; |
|
| 952 | + if ($globalDebug) { |
|
| 953 | 953 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 954 | 954 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 955 | 955 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -957,61 +957,61 @@ discard block |
||
| 957 | 957 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 958 | 958 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 959 | 959 | } |
| 960 | - } |
|
| 961 | - $ignoreImport = false; |
|
| 962 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 963 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 960 | + } |
|
| 961 | + $ignoreImport = false; |
|
| 962 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 963 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 964 | 964 | |
| 965 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 966 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 967 | - $ignoreImport = true; |
|
| 965 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 966 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 967 | + $ignoreImport = true; |
|
| 968 | + } |
|
| 968 | 969 | } |
| 969 | - } |
|
| 970 | - if (count($globalAirportAccept) > 0) { |
|
| 971 | - $ignoreImport = true; |
|
| 972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 973 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 970 | + if (count($globalAirportAccept) > 0) { |
|
| 971 | + $ignoreImport = true; |
|
| 972 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 973 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 974 | 974 | $ignoreImport = false; |
| 975 | - } |
|
| 975 | + } |
|
| 976 | 976 | } |
| 977 | - } |
|
| 978 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 977 | + } |
|
| 978 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 979 | 979 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 980 | - 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)) { |
|
| 980 | + 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)) { |
|
| 981 | 981 | $ignoreImport = true; |
| 982 | - } |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | - } |
|
| 985 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 984 | + } |
|
| 985 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 986 | 986 | $ignoreImport = true; |
| 987 | 987 | foreach($globalAirlineAccept as $airlineAccept) { |
| 988 | - 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)) { |
|
| 988 | + 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)) { |
|
| 989 | 989 | $ignoreImport = false; |
| 990 | - } |
|
| 990 | + } |
|
| 991 | + } |
|
| 991 | 992 | } |
| 992 | - } |
|
| 993 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 993 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 994 | 994 | $ignoreImport = true; |
| 995 | 995 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 996 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 997 | - $ignoreImport = false; |
|
| 998 | - } |
|
| 996 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 997 | + $ignoreImport = false; |
|
| 998 | + } |
|
| 999 | + } |
|
| 999 | 1000 | } |
| 1000 | - } |
|
| 1001 | 1001 | |
| 1002 | - if (!$ignoreImport) { |
|
| 1002 | + if (!$ignoreImport) { |
|
| 1003 | 1003 | 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'])) { |
| 1004 | 1004 | 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'))); |
| 1005 | 1005 | $timeelapsed = microtime(true); |
| 1006 | 1006 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 1007 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 1007 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 1008 | 1008 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 1009 | 1009 | $SpotterLive = new SpotterLive($this->db); |
| 1010 | 1010 | //var_dump($this->all_flights[$id]); |
| 1011 | 1011 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1012 | 1012 | $SpotterLive->db = null; |
| 1013 | 1013 | if ($globalDebug) echo $result."\n"; |
| 1014 | - } |
|
| 1014 | + } |
|
| 1015 | 1015 | } |
| 1016 | 1016 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 1017 | 1017 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | //if ($line['format_source'] != 'aprs') { |
| 1024 | 1024 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 1025 | 1025 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1026 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1026 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1027 | 1027 | $source = $this->all_flights[$id]['source_name']; |
| 1028 | 1028 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
| 1029 | 1029 | if (!isset($this->source_location[$source])) { |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | if ($stats_heading == 16) $stats_heading = 0; |
| 1050 | 1050 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1051 | 1051 | for ($i=0;$i<=15;$i++) { |
| 1052 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1052 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1053 | 1053 | } |
| 1054 | 1054 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 1055 | 1055 | } else { |
@@ -1062,17 +1062,17 @@ discard block |
||
| 1062 | 1062 | //var_dump($this->stats); |
| 1063 | 1063 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1064 | 1064 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1065 | - end($this->stats[$current_date][$source]['hist']); |
|
| 1066 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1065 | + end($this->stats[$current_date][$source]['hist']); |
|
| 1066 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1067 | 1067 | } else $mini = 0; |
| 1068 | 1068 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1069 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1069 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 1072 | 1072 | } else { |
| 1073 | 1073 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
| 1074 | 1074 | } |
| 1075 | - } |
|
| 1075 | + } |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | //$this->del(); |
| 1083 | 1083 | |
| 1084 | 1084 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1085 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1085 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1086 | 1086 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
| 1087 | 1087 | $SpotterLive = new SpotterLive($this->db); |
| 1088 | 1088 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1097,19 +1097,19 @@ discard block |
||
| 1097 | 1097 | if ($globalDebug) echo " Done\n"; |
| 1098 | 1098 | } |
| 1099 | 1099 | $this->last_delete_hourly = time(); |
| 1100 | - } else { |
|
| 1100 | + } else { |
|
| 1101 | 1101 | $this->del(); |
| 1102 | 1102 | $this->last_delete_hourly = time(); |
| 1103 | - } |
|
| 1103 | + } |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - } |
|
| 1107 | - //$ignoreImport = false; |
|
| 1106 | + } |
|
| 1107 | + //$ignoreImport = false; |
|
| 1108 | 1108 | } |
| 1109 | 1109 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1110 | 1110 | if ($send) return $this->all_flights[$id]; |
| 1111 | - } |
|
| 1111 | + } |
|
| 1112 | + } |
|
| 1112 | 1113 | } |
| 1113 | - } |
|
| 1114 | 1114 | } |
| 1115 | 1115 | ?> |
@@ -59,7 +59,9 @@ discard block |
||
| 59 | 59 | try { |
| 60 | 60 | $GeoidClass = new GeoidHeight(); |
| 61 | 61 | } catch(Exception $e) { |
| 62 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 62 | + if ($globalDebug) { |
|
| 63 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 64 | + } |
|
| 63 | 65 | $GeoidClass = FALSE; |
| 64 | 66 | } |
| 65 | 67 | } |
@@ -78,7 +80,9 @@ discard block |
||
| 78 | 80 | $dbc = $this->db; |
| 79 | 81 | $this->all_flights[$id]['schedule_check'] = true; |
| 80 | 82 | if ($globalSchedulesFetch) { |
| 81 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 83 | + if ($globalDebug) { |
|
| 84 | + echo 'Getting schedule info...'."\n"; |
|
| 85 | + } |
|
| 82 | 86 | $Spotter = new Spotter($dbc); |
| 83 | 87 | $Schedule = new Schedule($dbc); |
| 84 | 88 | $Translation = new Translation($dbc); |
@@ -89,7 +93,9 @@ discard block |
||
| 89 | 93 | if ($Schedule->checkSchedule($operator) == 0) { |
| 90 | 94 | $schedule = $Schedule->fetchSchedule($operator); |
| 91 | 95 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 98 | + } |
|
| 93 | 99 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 94 | 100 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 95 | 101 | // Should also check if route schedule = route from DB |
@@ -98,7 +104,9 @@ discard block |
||
| 98 | 104 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 99 | 105 | if (trim($airport_icao) != '') { |
| 100 | 106 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 101 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 109 | + } |
|
| 102 | 110 | } |
| 103 | 111 | } |
| 104 | 112 | } |
@@ -107,20 +115,30 @@ discard block |
||
| 107 | 115 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 108 | 116 | if (trim($airport_icao) != '') { |
| 109 | 117 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 110 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 118 | + if ($globalDebug) { |
|
| 119 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 120 | + } |
|
| 111 | 121 | } |
| 112 | 122 | } |
| 113 | 123 | } |
| 114 | 124 | $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']); |
| 115 | 125 | } |
| 116 | - } else $scheduleexist = true; |
|
| 117 | - } else $scheduleexist = true; |
|
| 126 | + } else { |
|
| 127 | + $scheduleexist = true; |
|
| 128 | + } |
|
| 129 | + } else { |
|
| 130 | + $scheduleexist = true; |
|
| 131 | + } |
|
| 118 | 132 | // close connection, at least one way will work ? |
| 119 | 133 | if ($scheduleexist) { |
| 120 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 136 | + } |
|
| 121 | 137 | $sch = $Schedule->getSchedule($operator); |
| 122 | 138 | $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'])); |
| 123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 139 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 140 | + $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 141 | + } |
|
| 124 | 142 | } |
| 125 | 143 | $Spotter->db = null; |
| 126 | 144 | $Schedule->db = null; |
@@ -140,14 +158,18 @@ discard block |
||
| 140 | 158 | |
| 141 | 159 | public function checkAll() { |
| 142 | 160 | global $globalDebug, $globalNoImport; |
| 143 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "Update last seen flights data...\n"; |
|
| 163 | + } |
|
| 144 | 164 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 145 | 165 | foreach ($this->all_flights as $key => $flight) { |
| 146 | 166 | if (isset($this->all_flights[$key]['id'])) { |
| 147 | 167 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 148 | 168 | $Spotter = new Spotter($this->db); |
| 149 | 169 | $real_arrival = $this->arrival($key); |
| 150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
| 170 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
| 171 | + $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']); |
|
| 172 | + } |
|
| 151 | 173 | } |
| 152 | 174 | } |
| 153 | 175 | } |
@@ -155,24 +177,32 @@ discard block |
||
| 155 | 177 | |
| 156 | 178 | public function arrival($key) { |
| 157 | 179 | global $globalClosestMinDist, $globalDebug; |
| 158 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 180 | + if ($globalDebug) { |
|
| 181 | + echo 'Update arrival...'."\n"; |
|
| 182 | + } |
|
| 159 | 183 | $Spotter = new Spotter($this->db); |
| 160 | 184 | $airport_icao = ''; |
| 161 | 185 | $airport_time = ''; |
| 162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 186 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 187 | + $globalClosestMinDist = 50; |
|
| 188 | + } |
|
| 163 | 189 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 164 | 190 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 165 | 191 | if (isset($closestAirports[0])) { |
| 166 | 192 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 167 | 193 | $airport_icao = $closestAirports[0]['icao']; |
| 168 | 194 | $airport_time = $this->all_flights[$key]['datetime']; |
| 169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 197 | + } |
|
| 170 | 198 | } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 171 | 199 | foreach ($closestAirports as $airport) { |
| 172 | 200 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 173 | 201 | $airport_icao = $airport['icao']; |
| 174 | 202 | $airport_time = $this->all_flights[$key]['datetime']; |
| 175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 205 | + } |
|
| 176 | 206 | break; |
| 177 | 207 | } |
| 178 | 208 | } |
@@ -180,14 +210,20 @@ discard block |
||
| 180 | 210 | $airport_icao = $closestAirports[0]['icao']; |
| 181 | 211 | $airport_time = $this->all_flights[$key]['datetime']; |
| 182 | 212 | } else { |
| 183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 215 | + } |
|
| 184 | 216 | } |
| 185 | 217 | } else { |
| 186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 218 | + if ($globalDebug) { |
|
| 219 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 220 | + } |
|
| 187 | 221 | } |
| 188 | 222 | |
| 189 | 223 | } else { |
| 190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 224 | + if ($globalDebug) { |
|
| 225 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 226 | + } |
|
| 191 | 227 | } |
| 192 | 228 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 193 | 229 | } |
@@ -197,7 +233,9 @@ discard block |
||
| 197 | 233 | public function del() { |
| 198 | 234 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 199 | 235 | // Delete old infos |
| 200 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 238 | + } |
|
| 201 | 239 | |
| 202 | 240 | foreach ($this->all_flights as $key => $flight) { |
| 203 | 241 | if (isset($flight['lastupdate'])) { |
@@ -212,22 +250,30 @@ discard block |
||
| 212 | 250 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 213 | 251 | // Delete old infos |
| 214 | 252 | if (isset($this->all_flights[$key]['id'])) { |
| 215 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 253 | + if ($globalDebug) { |
|
| 254 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 255 | + } |
|
| 216 | 256 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 217 | 257 | $real_arrival = $this->arrival($key); |
| 218 | 258 | $Spotter = new Spotter($this->db); |
| 219 | 259 | $SpotterLive = new SpotterLive($this->db); |
| 220 | 260 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 221 | 261 | $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']); |
| 222 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 262 | + if ($globalDebug && $result != 'success') { |
|
| 263 | + echo '!!! ERROR : '.$result."\n"; |
|
| 264 | + } |
|
| 223 | 265 | $this->all_flights[$key]['putinarchive'] = true; |
| 224 | 266 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
| 225 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 267 | + if ($globalDebug && $result != 'success') { |
|
| 268 | + echo '!!! ERROR : '.$result."\n"; |
|
| 269 | + } |
|
| 226 | 270 | } |
| 227 | 271 | $Spotter->db = null; |
| 228 | 272 | $SpotterLive->db = null; |
| 229 | 273 | } |
| 230 | - if ($globalDebug) echo "\n"; |
|
| 274 | + if ($globalDebug) { |
|
| 275 | + echo "\n"; |
|
| 276 | + } |
|
| 231 | 277 | } |
| 232 | 278 | unset($this->all_flights[$key]); |
| 233 | 279 | } |
@@ -235,9 +281,13 @@ discard block |
||
| 235 | 281 | public function add($line) { |
| 236 | 282 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive, $globalAPRSdelete; |
| 237 | 283 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 238 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
| 239 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
| 240 | -/* |
|
| 284 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 285 | + $globalCoordMinChange = '0.01'; |
|
| 286 | + } |
|
| 287 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
| 288 | + $globalAircraftMaxUpdate = 3000; |
|
| 289 | + } |
|
| 290 | + /* |
|
| 241 | 291 | $Spotter = new Spotter(); |
| 242 | 292 | $dbc = $Spotter->db; |
| 243 | 293 | $SpotterLive = new SpotterLive($dbc); |
@@ -259,19 +309,28 @@ discard block |
||
| 259 | 309 | // SBS format is CSV format |
| 260 | 310 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 261 | 311 | //print_r($line); |
| 262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 312 | + if (isset($line['hex'])) { |
|
| 313 | + $line['hex'] = strtoupper($line['hex']); |
|
| 314 | + } |
|
| 263 | 315 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
| 264 | 316 | |
| 265 | 317 | // Increment message number |
| 266 | 318 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 267 | 319 | $current_date = date('Y-m-d'); |
| 268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | - else $source = ''; |
|
| 270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 320 | + if (isset($line['source_name'])) { |
|
| 321 | + $source = $line['source_name']; |
|
| 322 | + } else { |
|
| 323 | + $source = ''; |
|
| 324 | + } |
|
| 325 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 326 | + $source = $line['format_source']; |
|
| 327 | + } |
|
| 271 | 328 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 272 | 329 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 273 | 330 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 331 | + } else { |
|
| 332 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 333 | + } |
|
| 275 | 334 | } |
| 276 | 335 | |
| 277 | 336 | /* |
@@ -287,23 +346,38 @@ discard block |
||
| 287 | 346 | //$this->db = $dbc; |
| 288 | 347 | |
| 289 | 348 | //$hex = trim($line['hex']); |
| 290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | - else $id = trim($line['id']); |
|
| 349 | + if (!isset($line['id'])) { |
|
| 350 | + $id = trim($line['hex']); |
|
| 351 | + } else { |
|
| 352 | + $id = trim($line['id']); |
|
| 353 | + } |
|
| 292 | 354 | |
| 293 | 355 | if (!isset($this->all_flights[$id])) { |
| 294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 356 | + if ($globalDebug) { |
|
| 357 | + echo 'New flight...'."\n"; |
|
| 358 | + } |
|
| 295 | 359 | $this->all_flights[$id] = array(); |
| 296 | 360 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 297 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
| 298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 362 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
| 363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 364 | + } |
|
| 299 | 365 | if (!isset($line['id'])) { |
| 300 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 301 | -// 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'))); |
|
| 366 | + if (!isset($globalDaemon)) { |
|
| 367 | + $globalDaemon = TRUE; |
|
| 368 | + } |
|
| 369 | + // 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'))); |
|
| 302 | 370 | // 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'))); |
| 303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 371 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 373 | + } |
|
| 304 | 374 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 375 | + } else { |
|
| 376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 377 | + } |
|
| 378 | + if ($globalAllFlights !== FALSE) { |
|
| 379 | + $dataFound = true; |
|
| 380 | + } |
|
| 307 | 381 | } |
| 308 | 382 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 309 | 383 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -325,12 +399,20 @@ discard block |
||
| 325 | 399 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 326 | 400 | } |
| 327 | 401 | $Spotter->db = null; |
| 328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 402 | + if ($globalDebugTimeElapsed) { |
|
| 403 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 404 | + } |
|
| 405 | + if ($aircraft_icao != '') { |
|
| 406 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 407 | + } |
|
| 330 | 408 | } |
| 331 | 409 | } |
| 332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 410 | + if ($globalAllFlights !== FALSE) { |
|
| 411 | + $dataFound = true; |
|
| 412 | + } |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 415 | + } |
|
| 334 | 416 | } |
| 335 | 417 | if (isset($line['id']) && !isset($line['hex'])) { |
| 336 | 418 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -339,7 +421,9 @@ discard block |
||
| 339 | 421 | $icao = $line['aircraft_icao']; |
| 340 | 422 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 341 | 423 | $Spotter = new Spotter($this->db); |
| 342 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 424 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
| 425 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 426 | + } |
|
| 343 | 427 | $Spotter->db = null; |
| 344 | 428 | } |
| 345 | 429 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -349,15 +433,24 @@ discard block |
||
| 349 | 433 | $Spotter = new Spotter($this->db); |
| 350 | 434 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 351 | 435 | $Spotter->db = null; |
| 352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 436 | + if ($aircraft_icao != '') { |
|
| 437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 438 | + } |
|
| 353 | 439 | } |
| 354 | 440 | } |
| 355 | 441 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 356 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 357 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 358 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 359 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 442 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 443 | + $aircraft_icao = 'GLID'; |
|
| 444 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 445 | + $aircraft_icao = 'UHEL'; |
|
| 446 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 447 | + $aircraft_icao = 'TOWPLANE'; |
|
| 448 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 449 | + $aircraft_icao = 'POWAIRC'; |
|
| 450 | + } |
|
| 451 | + if (isset($aircraft_icao)) { |
|
| 452 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 453 | + } |
|
| 361 | 454 | } |
| 362 | 455 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 363 | 456 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -367,8 +460,11 @@ discard block |
||
| 367 | 460 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 368 | 461 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 369 | 462 | } else { |
| 370 | - 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"; |
|
| 371 | - 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"; |
|
| 463 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 464 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 465 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 466 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 467 | + } |
|
| 372 | 468 | /* |
| 373 | 469 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 374 | 470 | print_r($this->all_flights[$id]); |
@@ -377,16 +473,22 @@ discard block |
||
| 377 | 473 | return ''; |
| 378 | 474 | } |
| 379 | 475 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 380 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 476 | + if ($globalDebug) { |
|
| 477 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 478 | + } |
|
| 381 | 479 | return ''; |
| 382 | 480 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 383 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 481 | + if ($globalDebug) { |
|
| 482 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 483 | + } |
|
| 384 | 484 | return ''; |
| 385 | 485 | } elseif (!isset($line['datetime'])) { |
| 386 | 486 | date_default_timezone_set('UTC'); |
| 387 | 487 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 388 | 488 | } else { |
| 389 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 489 | + if ($globalDebug) { |
|
| 490 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 491 | + } |
|
| 390 | 492 | return ''; |
| 391 | 493 | } |
| 392 | 494 | |
@@ -407,30 +509,48 @@ discard block |
||
| 407 | 509 | |
| 408 | 510 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 409 | 511 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 410 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 512 | + if ($globalDebug) { |
|
| 513 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 514 | + } |
|
| 411 | 515 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 412 | 516 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 415 | - 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'])); |
|
| 517 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 518 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 519 | + } elseif (isset($line['id'])) { |
|
| 520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 521 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 522 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 523 | + } |
|
| 416 | 524 | } else { |
| 417 | 525 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
| 418 | 526 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 419 | 527 | $timeelapsed = microtime(true); |
| 420 | 528 | $Spotter = new Spotter($this->db); |
| 421 | 529 | $fromsource = NULL; |
| 422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 424 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 425 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 426 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 530 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 531 | + $fromsource = $globalAirlinesSource; |
|
| 532 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 533 | + $fromsource = 'vatsim'; |
|
| 534 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 535 | + $fromsource = 'ivao'; |
|
| 536 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 537 | + $fromsource = 'vatsim'; |
|
| 538 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 539 | + $fromsource = 'ivao'; |
|
| 540 | + } |
|
| 427 | 541 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
| 428 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 542 | + if ($globalDebug && $result != 'success') { |
|
| 543 | + echo '!!! ERROR : '.$result."\n"; |
|
| 544 | + } |
|
| 429 | 545 | $Spotter->db = null; |
| 430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 546 | + if ($globalDebugTimeElapsed) { |
|
| 547 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 548 | + } |
|
| 431 | 549 | } |
| 432 | 550 | } |
| 433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 551 | + } else { |
|
| 552 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 553 | + } |
|
| 434 | 554 | |
| 435 | 555 | /* |
| 436 | 556 | if (!isset($line['id'])) { |
@@ -440,7 +560,9 @@ discard block |
||
| 440 | 560 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 441 | 561 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 442 | 562 | */ |
| 443 | - 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'])); |
|
| 563 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 564 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 565 | + } |
|
| 444 | 566 | |
| 445 | 567 | //$putinarchive = true; |
| 446 | 568 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -458,7 +580,9 @@ discard block |
||
| 458 | 580 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 459 | 581 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 460 | 582 | $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' => '')); |
| 461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 583 | + if ($globalDebugTimeElapsed) { |
|
| 584 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 585 | + } |
|
| 462 | 586 | } |
| 463 | 587 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 464 | 588 | $timeelapsed = microtime(true); |
@@ -472,7 +596,9 @@ discard block |
||
| 472 | 596 | $Translation->db = null; |
| 473 | 597 | } |
| 474 | 598 | $Spotter->db = null; |
| 475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 599 | + if ($globalDebugTimeElapsed) { |
|
| 600 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 601 | + } |
|
| 476 | 602 | } |
| 477 | 603 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 478 | 604 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -481,9 +607,13 @@ discard block |
||
| 481 | 607 | $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'])); |
| 482 | 608 | } |
| 483 | 609 | } |
| 484 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 610 | + if (!isset($globalFork)) { |
|
| 611 | + $globalFork = TRUE; |
|
| 612 | + } |
|
| 485 | 613 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 614 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 615 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 616 | + } |
|
| 487 | 617 | } |
| 488 | 618 | } |
| 489 | 619 | } |
@@ -501,9 +631,13 @@ discard block |
||
| 501 | 631 | $speed = $speed*3.6; |
| 502 | 632 | if ($speed < 1000) { |
| 503 | 633 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 504 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 634 | + if ($globalDebug) { |
|
| 635 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 636 | + } |
|
| 505 | 637 | } else { |
| 506 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 638 | + if ($globalDebug) { |
|
| 639 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 640 | + } |
|
| 507 | 641 | } |
| 508 | 642 | } |
| 509 | 643 | } |
@@ -512,13 +646,21 @@ discard block |
||
| 512 | 646 | |
| 513 | 647 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 514 | 648 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
| 515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 649 | + if ($globalDebug) { |
|
| 650 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 651 | + } |
|
| 516 | 652 | return false; |
| 517 | 653 | } |
| 518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | - else unset($timediff); |
|
| 520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | - else unset($timediff_archive); |
|
| 654 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 655 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 656 | + } else { |
|
| 657 | + unset($timediff); |
|
| 658 | + } |
|
| 659 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
| 660 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 661 | + } else { |
|
| 662 | + unset($timediff_archive); |
|
| 663 | + } |
|
| 522 | 664 | if ($this->tmd > 5 |
| 523 | 665 | || (isset($line['format_source']) |
| 524 | 666 | && $line['format_source'] == 'airwhere' |
@@ -554,21 +696,32 @@ discard block |
||
| 554 | 696 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 555 | 697 | $this->all_flights[$id]['putinarchive'] = true; |
| 556 | 698 | if ($this->tmd > 5 && $this->all_flights[$id]['putinarchive'] == true) { |
| 557 | - if ($globalDebug) echo "\n".' Update Initial data ! '."\n"; |
|
| 699 | + if ($globalDebug) { |
|
| 700 | + echo "\n".' Update Initial data ! '."\n"; |
|
| 701 | + } |
|
| 558 | 702 | $updateinitial = true; |
| 559 | 703 | } |
| 560 | 704 | $this->tmd = 0; |
| 561 | 705 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 562 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 706 | + if ($globalDebug) { |
|
| 707 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 708 | + } |
|
| 563 | 709 | $timeelapsed = microtime(true); |
| 564 | 710 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 565 | 711 | $Spotter = new Spotter($this->db); |
| 566 | 712 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 567 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 568 | - else $this->all_flights[$id]['over_country'] = ''; |
|
| 713 | + if (!empty($all_country)) { |
|
| 714 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 715 | + } else { |
|
| 716 | + $this->all_flights[$id]['over_country'] = ''; |
|
| 717 | + } |
|
| 569 | 718 | $Spotter->db = null; |
| 570 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 571 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 719 | + if ($globalDebugTimeElapsed) { |
|
| 720 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 721 | + } |
|
| 722 | + if ($globalDebug) { |
|
| 723 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 724 | + } |
|
| 572 | 725 | } |
| 573 | 726 | } |
| 574 | 727 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -614,7 +767,9 @@ discard block |
||
| 614 | 767 | */ |
| 615 | 768 | } |
| 616 | 769 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 617 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 770 | + if ($line['longitude'] > 180) { |
|
| 771 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 772 | + } |
|
| 618 | 773 | //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) { |
| 619 | 774 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 620 | 775 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -643,7 +798,9 @@ discard block |
||
| 643 | 798 | */ |
| 644 | 799 | } |
| 645 | 800 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
| 646 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 801 | + if ($globalDebug) { |
|
| 802 | + echo "\n".'>>> Update initial data !'."\n"; |
|
| 803 | + } |
|
| 647 | 804 | unset($updateinitial); |
| 648 | 805 | $SpotterArchive = new SpotterArchive(); |
| 649 | 806 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
@@ -661,7 +818,9 @@ discard block |
||
| 661 | 818 | } |
| 662 | 819 | } |
| 663 | 820 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 664 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 821 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 822 | + $dataFound = true; |
|
| 823 | + } |
|
| 665 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 666 | 825 | } |
| 667 | 826 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -683,35 +842,53 @@ discard block |
||
| 683 | 842 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 684 | 843 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 685 | 844 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 686 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 688 | - 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'])); |
|
| 845 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 846 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 847 | + } elseif (isset($line['id'])) { |
|
| 848 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 849 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 850 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 851 | + } |
|
| 852 | + } |
|
| 853 | + if ($line['ground'] != 1) { |
|
| 854 | + $line['ground'] = 0; |
|
| 689 | 855 | } |
| 690 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | 856 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 692 | 857 | //$dataFound = true; |
| 693 | 858 | } |
| 694 | 859 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 695 | 860 | 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'])) { |
| 696 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 861 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 862 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 863 | + } |
|
| 697 | 864 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 698 | 865 | $highlight = ''; |
| 699 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 866 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 867 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 868 | + } |
|
| 869 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 870 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 871 | + } |
|
| 872 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 873 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 874 | + } |
|
| 702 | 875 | if ($highlight != '') { |
| 703 | 876 | $timeelapsed = microtime(true); |
| 704 | 877 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 705 | 878 | $Spotter = new Spotter($this->db); |
| 706 | 879 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 707 | 880 | $Spotter->db = null; |
| 708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 881 | + if ($globalDebugTimeElapsed) { |
|
| 882 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 883 | + } |
|
| 709 | 884 | } |
| 710 | 885 | //$putinarchive = true; |
| 711 | 886 | //$highlight = ''; |
| 712 | 887 | } |
| 713 | 888 | |
| 714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 889 | + } else { |
|
| 890 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 891 | + } |
|
| 715 | 892 | //$dataFound = true; |
| 716 | 893 | } |
| 717 | 894 | |
@@ -724,19 +901,27 @@ discard block |
||
| 724 | 901 | } |
| 725 | 902 | } |
| 726 | 903 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 727 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 904 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 905 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 906 | + } |
|
| 728 | 907 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 729 | 908 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 730 | 909 | //$dataFound = true; |
| 731 | 910 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 732 | 911 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 733 | 912 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 734 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
| 913 | + if ($globalDebug) { |
|
| 914 | + echo '--- Reset because of altitude'."\n"; |
|
| 915 | + } |
|
| 735 | 916 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 736 | 917 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 737 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 738 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 739 | - 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'])); |
|
| 918 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
|
| 919 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 920 | + } elseif (isset($line['id'])) { |
|
| 921 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 922 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 923 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 924 | + } |
|
| 740 | 925 | } |
| 741 | 926 | } |
| 742 | 927 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -747,22 +932,32 @@ discard block |
||
| 747 | 932 | } |
| 748 | 933 | |
| 749 | 934 | if (isset($line['heading']) && $line['heading'] != '') { |
| 750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 935 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 936 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 937 | + } |
|
| 751 | 938 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 752 | 939 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 753 | 940 | //$dataFound = true; |
| 754 | 941 | } 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']) { |
| 755 | 942 | $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']); |
| 756 | 943 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 944 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 945 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 946 | + } |
|
| 947 | + if ($globalDebug) { |
|
| 948 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 949 | + } |
|
| 759 | 950 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 760 | 951 | // If not enough messages and ACARS set heading to 0 |
| 761 | 952 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 762 | 953 | } |
| 763 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 764 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 765 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
| 954 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 955 | + $dataFound = false; |
|
| 956 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 957 | + $dataFound = false; |
|
| 958 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) { |
|
| 959 | + $dataFound = false; |
|
| 960 | + } |
|
| 766 | 961 | |
| 767 | 962 | // print_r($this->all_flights[$id]); |
| 768 | 963 | //gets the callsign from the last hour |
@@ -779,23 +974,38 @@ discard block |
||
| 779 | 974 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 780 | 975 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 781 | 976 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 782 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 977 | + if ($globalDebug) { |
|
| 978 | + echo "Check if aircraft is already in DB..."; |
|
| 979 | + } |
|
| 783 | 980 | $timeelapsed = microtime(true); |
| 784 | 981 | $SpotterLive = new SpotterLive($this->db); |
| 785 | 982 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) { |
| 786 | 983 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 787 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 984 | + if ($globalDebugTimeElapsed) { |
|
| 985 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 986 | + } |
|
| 788 | 987 | } elseif (isset($line['id'])) { |
| 789 | 988 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 989 | + if ($globalDebugTimeElapsed) { |
|
| 990 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 991 | + } |
|
| 791 | 992 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 792 | 993 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 793 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 794 | - } else $recent_ident = ''; |
|
| 994 | + if ($globalDebugTimeElapsed) { |
|
| 995 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 996 | + } |
|
| 997 | + } else { |
|
| 998 | + $recent_ident = ''; |
|
| 999 | + } |
|
| 795 | 1000 | $SpotterLive->db=null; |
| 796 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 798 | - } else $recent_ident = ''; |
|
| 1001 | + if ($globalDebug && $recent_ident == '') { |
|
| 1002 | + echo " Not in DB.\n"; |
|
| 1003 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 1004 | + echo " Already in DB.\n"; |
|
| 1005 | + } |
|
| 1006 | + } else { |
|
| 1007 | + $recent_ident = ''; |
|
| 1008 | + } |
|
| 799 | 1009 | } else { |
| 800 | 1010 | $recent_ident = ''; |
| 801 | 1011 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -803,7 +1013,9 @@ discard block |
||
| 803 | 1013 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 804 | 1014 | if($recent_ident == "") |
| 805 | 1015 | { |
| 806 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 1016 | + if ($globalDebug) { |
|
| 1017 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 1018 | + } |
|
| 807 | 1019 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 808 | 1020 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 809 | 1021 | //adds the spotter data for the archive |
@@ -847,10 +1059,18 @@ discard block |
||
| 847 | 1059 | |
| 848 | 1060 | if (!$ignoreImport) { |
| 849 | 1061 | $highlight = ''; |
| 850 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | - 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'))); |
|
| 1062 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 1063 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 1064 | + } |
|
| 1065 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 1066 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 1067 | + } |
|
| 1068 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 1069 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 1070 | + } |
|
| 1071 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1072 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1073 | + } |
|
| 854 | 1074 | $timeelapsed = microtime(true); |
| 855 | 1075 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 856 | 1076 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -858,28 +1078,43 @@ discard block |
||
| 858 | 1078 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
| 859 | 1079 | $Spotter->db = null; |
| 860 | 1080 | if ($globalDebug) { |
| 861 | - if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
| 862 | - else echo 'Success'; |
|
| 1081 | + if (isset($result['error'])) { |
|
| 1082 | + echo 'Error: '.$result['error']."\n"; |
|
| 1083 | + } else { |
|
| 1084 | + echo 'Success'; |
|
| 1085 | + } |
|
| 863 | 1086 | } |
| 864 | 1087 | if (count($result) > 1) { |
| 865 | 1088 | // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
| 866 | - if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 867 | - if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1089 | + if ($this->all_flights[$id]['aircraft_icao'] == '') { |
|
| 1090 | + $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 1091 | + } |
|
| 1092 | + if ($this->all_flights[$id]['registration'] == '') { |
|
| 1093 | + $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1094 | + } |
|
| 868 | 1095 | } |
| 869 | 1096 | } |
| 870 | 1097 | } |
| 871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1098 | + if ($globalDebugTimeElapsed) { |
|
| 1099 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1100 | + } |
|
| 872 | 1101 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 873 | 1102 | |
| 874 | 1103 | // Add source stat in DB |
| 875 | 1104 | $Stats = new Stats($this->db); |
| 876 | 1105 | if (!empty($this->stats)) { |
| 877 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 1106 | + if ($globalDebug) { |
|
| 1107 | + echo 'Add source stats : '; |
|
| 1108 | + } |
|
| 878 | 1109 | foreach($this->stats as $date => $data) { |
| 879 | 1110 | foreach($data as $source => $sourced) { |
| 880 | 1111 | //print_r($sourced); |
| 881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1112 | + if (isset($sourced['polar'])) { |
|
| 1113 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 1114 | + } |
|
| 1115 | + if (isset($sourced['hist'])) { |
|
| 1116 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1117 | + } |
|
| 883 | 1118 | if (isset($sourced['msg'])) { |
| 884 | 1119 | if (time() - $sourced['msg']['date'] > 10) { |
| 885 | 1120 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -892,13 +1127,17 @@ discard block |
||
| 892 | 1127 | unset($this->stats[$date]); |
| 893 | 1128 | } |
| 894 | 1129 | } |
| 895 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1130 | + if ($globalDebug) { |
|
| 1131 | + echo 'Done'."\n"; |
|
| 1132 | + } |
|
| 896 | 1133 | |
| 897 | 1134 | } |
| 898 | 1135 | $Stats->db = null; |
| 899 | 1136 | } |
| 900 | 1137 | $this->del(); |
| 901 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 1138 | + } elseif ($globalDebug) { |
|
| 1139 | + echo 'Ignore data'."\n"; |
|
| 1140 | + } |
|
| 902 | 1141 | //$ignoreImport = false; |
| 903 | 1142 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 904 | 1143 | //print_r($this->all_flights[$id]); |
@@ -915,7 +1154,9 @@ discard block |
||
| 915 | 1154 | */ |
| 916 | 1155 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 917 | 1156 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 918 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1157 | + if ($globalDebug) { |
|
| 1158 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1159 | + } |
|
| 919 | 1160 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 920 | 1161 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 921 | 1162 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -924,7 +1165,9 @@ discard block |
||
| 924 | 1165 | $SpotterLive->db=null; |
| 925 | 1166 | } |
| 926 | 1167 | } |
| 927 | - if ($globalDebug) echo " Done\n"; |
|
| 1168 | + if ($globalDebug) { |
|
| 1169 | + echo " Done\n"; |
|
| 1170 | + } |
|
| 928 | 1171 | $this->last_delete = time(); |
| 929 | 1172 | } |
| 930 | 1173 | } else { |
@@ -951,11 +1194,17 @@ discard block |
||
| 951 | 1194 | //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"; |
| 952 | 1195 | if ($globalDebug) { |
| 953 | 1196 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 954 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 955 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1197 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1198 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1199 | + } else { |
|
| 1200 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1201 | + } |
|
| 956 | 1202 | } else { |
| 957 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 958 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1203 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1204 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1205 | + } else { |
|
| 1206 | + 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"; |
|
| 1207 | + } |
|
| 959 | 1208 | } |
| 960 | 1209 | } |
| 961 | 1210 | $ignoreImport = false; |
@@ -1001,23 +1250,31 @@ discard block |
||
| 1001 | 1250 | |
| 1002 | 1251 | if (!$ignoreImport) { |
| 1003 | 1252 | 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'])) { |
| 1004 | - 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'))); |
|
| 1253 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1254 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1255 | + } |
|
| 1005 | 1256 | $timeelapsed = microtime(true); |
| 1006 | 1257 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 1007 | 1258 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1008 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1259 | + if ($globalDebug) { |
|
| 1260 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1261 | + } |
|
| 1009 | 1262 | $SpotterLive = new SpotterLive($this->db); |
| 1010 | 1263 | //var_dump($this->all_flights[$id]); |
| 1011 | 1264 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1012 | 1265 | $SpotterLive->db = null; |
| 1013 | - if ($globalDebug) echo $result."\n"; |
|
| 1266 | + if ($globalDebug) { |
|
| 1267 | + echo $result."\n"; |
|
| 1268 | + } |
|
| 1014 | 1269 | } |
| 1015 | 1270 | } |
| 1016 | 1271 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 1017 | 1272 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1018 | 1273 | } |
| 1019 | 1274 | $this->all_flights[$id]['putinarchive'] = false; |
| 1020 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1275 | + if ($globalDebugTimeElapsed) { |
|
| 1276 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1277 | + } |
|
| 1021 | 1278 | |
| 1022 | 1279 | // Put statistics in $this->stats variable |
| 1023 | 1280 | //if ($line['format_source'] != 'aprs') { |
@@ -1025,7 +1282,9 @@ discard block |
||
| 1025 | 1282 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1026 | 1283 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 1027 | 1284 | $source = $this->all_flights[$id]['source_name']; |
| 1028 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1285 | + if ($source == '') { |
|
| 1286 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1287 | + } |
|
| 1029 | 1288 | if (!isset($this->source_location[$source])) { |
| 1030 | 1289 | $Location = new Source($this->db); |
| 1031 | 1290 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1046,7 +1305,9 @@ discard block |
||
| 1046 | 1305 | $stats_heading = round($stats_heading/22.5); |
| 1047 | 1306 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 1048 | 1307 | $current_date = date('Y-m-d'); |
| 1049 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1308 | + if ($stats_heading == 16) { |
|
| 1309 | + $stats_heading = 0; |
|
| 1310 | + } |
|
| 1050 | 1311 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1051 | 1312 | for ($i=0;$i<=15;$i++) { |
| 1052 | 1313 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1064,7 +1325,9 @@ discard block |
||
| 1064 | 1325 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1065 | 1326 | end($this->stats[$current_date][$source]['hist']); |
| 1066 | 1327 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 1067 | - } else $mini = 0; |
|
| 1328 | + } else { |
|
| 1329 | + $mini = 0; |
|
| 1330 | + } |
|
| 1068 | 1331 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1069 | 1332 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1070 | 1333 | } |
@@ -1076,25 +1339,37 @@ discard block |
||
| 1076 | 1339 | } |
| 1077 | 1340 | |
| 1078 | 1341 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1079 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1342 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1343 | + $send = true; |
|
| 1344 | + } |
|
| 1080 | 1345 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1081 | - } 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"; |
|
| 1346 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1347 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1348 | + } |
|
| 1082 | 1349 | //$this->del(); |
| 1083 | 1350 | |
| 1084 | 1351 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1085 | 1352 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 1086 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1353 | + if ($globalDebug) { |
|
| 1354 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1355 | + } |
|
| 1087 | 1356 | $SpotterLive = new SpotterLive($this->db); |
| 1088 | 1357 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 1089 | 1358 | $SpotterLive->db = null; |
| 1090 | 1359 | //SpotterLive->deleteLiveSpotterData(); |
| 1091 | - if ($globalDebug) echo " Done\n"; |
|
| 1360 | + if ($globalDebug) { |
|
| 1361 | + echo " Done\n"; |
|
| 1362 | + } |
|
| 1092 | 1363 | if (isset($globalAPRSdelete) && $globalAPRSdelete) { |
| 1093 | - if ($globalDebug) echo "---- Deleting old APRS data..."; |
|
| 1364 | + if ($globalDebug) { |
|
| 1365 | + echo "---- Deleting old APRS data..."; |
|
| 1366 | + } |
|
| 1094 | 1367 | $Spotter = new Spotter($this->db); |
| 1095 | 1368 | $Spotter->deleteOldAPRSData(); |
| 1096 | 1369 | $Spotter->db = null; |
| 1097 | - if ($globalDebug) echo " Done\n"; |
|
| 1370 | + if ($globalDebug) { |
|
| 1371 | + echo " Done\n"; |
|
| 1372 | + } |
|
| 1098 | 1373 | } |
| 1099 | 1374 | $this->last_delete_hourly = time(); |
| 1100 | 1375 | } else { |
@@ -1107,7 +1382,9 @@ discard block |
||
| 1107 | 1382 | //$ignoreImport = false; |
| 1108 | 1383 | } |
| 1109 | 1384 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1110 | - if ($send) return $this->all_flights[$id]; |
|
| 1385 | + if ($send) { |
|
| 1386 | + return $this->all_flights[$id]; |
|
| 1387 | + } |
|
| 1111 | 1388 | } |
| 1112 | 1389 | } |
| 1113 | 1390 | } |