@@ -9,20 +9,20 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class SpotterImport { |
| 16 | - private $all_flights = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_flights = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
| 27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
| 28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | $currentdate = date('Y-m-d'); |
| 35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 36 | 36 | if (!empty($sourcestat)) { |
| 37 | - foreach($sourcestat as $srcst) { |
|
| 38 | - $type = $srcst['stats_type']; |
|
| 37 | + foreach($sourcestat as $srcst) { |
|
| 38 | + $type = $srcst['stats_type']; |
|
| 39 | 39 | if ($type == 'polar' || $type == 'hist') { |
| 40 | - $source = $srcst['source_name']; |
|
| 41 | - $data = $srcst['source_data']; |
|
| 42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 43 | - } |
|
| 44 | - } |
|
| 40 | + $source = $srcst['source_name']; |
|
| 41 | + $data = $srcst['source_data']; |
|
| 42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | $GeoidClass = FALSE; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function get_Schedule($id,$ident) { |
|
| 61 | + public function get_Schedule($id,$ident) { |
|
| 62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 63 | 63 | // Get schedule here, so it's done only one time |
| 64 | 64 | |
@@ -78,43 +78,43 @@ discard block |
||
| 78 | 78 | $operator = $Spotter->getOperator($ident); |
| 79 | 79 | $scheduleexist = false; |
| 80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
| 81 | - $operator = $Translation->checkTranslation($ident); |
|
| 82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 81 | + $operator = $Translation->checkTranslation($ident); |
|
| 82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | - // Should also check if route schedule = route from DB |
|
| 89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | + // Should also check if route schedule = route from DB |
|
| 89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 92 | - if (trim($airport_icao) != '') { |
|
| 91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 92 | + if (trim($airport_icao) != '') { |
|
| 93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 95 | - } |
|
| 95 | + } |
|
| 96 | + } |
|
| 96 | 97 | } |
| 97 | - } |
|
| 98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 101 | - if (trim($airport_icao) != '') { |
|
| 100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 101 | + if (trim($airport_icao) != '') { |
|
| 102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | - } |
|
| 107 | - $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']); |
|
| 106 | + } |
|
| 107 | + $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']); |
|
| 108 | 108 | } |
| 109 | - } else $scheduleexist = true; |
|
| 109 | + } else $scheduleexist = true; |
|
| 110 | 110 | } else $scheduleexist = true; |
| 111 | 111 | // close connection, at least one way will work ? |
| 112 | - if ($scheduleexist) { |
|
| 112 | + if ($scheduleexist) { |
|
| 113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 114 | - $sch = $Schedule->getSchedule($operator); |
|
| 114 | + $sch = $Schedule->getSchedule($operator); |
|
| 115 | 115 | $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'])); |
| 116 | 116 | 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']); |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | $Spotter->db = null; |
| 119 | 119 | $Schedule->db = null; |
| 120 | 120 | $Translation->db = null; |
@@ -129,78 +129,78 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | */ |
| 131 | 131 | } |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - public function checkAll() { |
|
| 134 | + public function checkAll() { |
|
| 135 | 135 | global $globalDebug, $globalNoImport; |
| 136 | 136 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 137 | 137 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 138 | - foreach ($this->all_flights as $key => $flight) { |
|
| 138 | + foreach ($this->all_flights as $key => $flight) { |
|
| 139 | 139 | if (isset($this->all_flights[$key]['id'])) { |
| 140 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 141 | - $Spotter = new Spotter($this->db); |
|
| 142 | - $real_arrival = $this->arrival($key); |
|
| 143 | - 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']); |
|
| 144 | - } |
|
| 145 | - } |
|
| 140 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 141 | + $Spotter = new Spotter($this->db); |
|
| 142 | + $real_arrival = $this->arrival($key); |
|
| 143 | + 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']); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 146 | 147 | } |
| 147 | - } |
|
| 148 | 148 | |
| 149 | - public function arrival($key) { |
|
| 149 | + public function arrival($key) { |
|
| 150 | 150 | global $globalClosestMinDist, $globalDebug; |
| 151 | 151 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 152 | 152 | $Spotter = new Spotter($this->db); |
| 153 | - $airport_icao = ''; |
|
| 154 | - $airport_time = ''; |
|
| 155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 153 | + $airport_icao = ''; |
|
| 154 | + $airport_time = ''; |
|
| 155 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 156 | 156 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 157 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 158 | - if (isset($closestAirports[0])) { |
|
| 159 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 160 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 161 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 163 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 164 | - foreach ($closestAirports as $airport) { |
|
| 165 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 166 | - $airport_icao = $airport['icao']; |
|
| 167 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 169 | - break; |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - } 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))) { |
|
| 173 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | - } else { |
|
| 176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 177 | - } |
|
| 178 | - } else { |
|
| 179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 180 | - } |
|
| 157 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 158 | + if (isset($closestAirports[0])) { |
|
| 159 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 160 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 161 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 162 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 163 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 164 | + foreach ($closestAirports as $airport) { |
|
| 165 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 166 | + $airport_icao = $airport['icao']; |
|
| 167 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 168 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 169 | + break; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + } 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))) { |
|
| 173 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | + } else { |
|
| 176 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 177 | + } |
|
| 178 | + } else { |
|
| 179 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - } else { |
|
| 183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 184 | - } |
|
| 185 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 186 | - } |
|
| 182 | + } else { |
|
| 183 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 184 | + } |
|
| 185 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | - public function del() { |
|
| 190 | + public function del() { |
|
| 191 | 191 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 192 | 192 | // Delete old infos |
| 193 | 193 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 194 | 194 | foreach ($this->all_flights as $key => $flight) { |
| 195 | - if (isset($flight['lastupdate'])) { |
|
| 195 | + if (isset($flight['lastupdate'])) { |
|
| 196 | 196 | if ($flight['lastupdate'] < (time()-1800)) { |
| 197 | - $this->delKey($key); |
|
| 197 | + $this->delKey($key); |
|
| 198 | + } |
|
| 198 | 199 | } |
| 199 | - } |
|
| 200 | 200 | } |
| 201 | - } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - public function delKey($key) { |
|
| 203 | + public function delKey($key) { |
|
| 204 | 204 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 205 | 205 | // Delete old infos |
| 206 | 206 | if (isset($this->all_flights[$key]['id'])) { |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | unset($this->all_flights[$key]); |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - public function add($line) { |
|
| 226 | + public function add($line) { |
|
| 227 | 227 | 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; |
| 228 | 228 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 229 | 229 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -249,20 +249,20 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // SBS format is CSV format |
| 251 | 251 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 252 | - //print_r($line); |
|
| 253 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 254 | - 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)) { |
|
| 252 | + //print_r($line); |
|
| 253 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 254 | + 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)) { |
|
| 255 | 255 | |
| 256 | 256 | // Increment message number |
| 257 | 257 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 258 | - $current_date = date('Y-m-d'); |
|
| 259 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 260 | - else $source = ''; |
|
| 261 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 262 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 263 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 264 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 265 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 258 | + $current_date = date('Y-m-d'); |
|
| 259 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 260 | + else $source = ''; |
|
| 261 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 262 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 263 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 264 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 265 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /* |
@@ -278,54 +278,54 @@ discard block |
||
| 278 | 278 | //$this->db = $dbc; |
| 279 | 279 | |
| 280 | 280 | //$hex = trim($line['hex']); |
| 281 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 282 | - else $id = trim($line['id']); |
|
| 281 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 282 | + else $id = trim($line['id']); |
|
| 283 | 283 | |
| 284 | 284 | if (!isset($this->all_flights[$id])) { |
| 285 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 286 | - $this->all_flights[$id] = array(); |
|
| 287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 288 | - $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' => '')); |
|
| 289 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 290 | - if (!isset($line['id'])) { |
|
| 285 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
| 286 | + $this->all_flights[$id] = array(); |
|
| 287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 288 | + $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' => '')); |
|
| 289 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 290 | + if (!isset($line['id'])) { |
|
| 291 | 291 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 292 | 292 | // 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'))); |
| 293 | 293 | // 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'))); |
| 294 | 294 | 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'))); |
| 295 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 296 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 297 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 295 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 296 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 297 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 298 | 298 | } |
| 299 | 299 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 300 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 300 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | //print_r($this->all_flights); |
| 304 | 304 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 305 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 306 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 305 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 306 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 307 | 307 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 308 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 309 | - 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') { |
|
| 308 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 309 | + 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') { |
|
| 310 | 310 | $timeelapsed = microtime(true); |
| 311 | 311 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 312 | - $Spotter = new Spotter($this->db); |
|
| 313 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
| 312 | + $Spotter = new Spotter($this->db); |
|
| 313 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
| 314 | 314 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
| 315 | - } else { |
|
| 315 | + } else { |
|
| 316 | 316 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 317 | - } |
|
| 318 | - $Spotter->db = null; |
|
| 319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 320 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 317 | + } |
|
| 318 | + $Spotter->db = null; |
|
| 319 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 320 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 321 | + } |
|
| 321 | 322 | } |
| 322 | - } |
|
| 323 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 324 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 323 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 324 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 325 | 325 | } |
| 326 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
| 327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 328 | - } |
|
| 326 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
| 327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 328 | + } |
|
| 329 | 329 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 330 | 330 | $icao = $line['aircraft_icao']; |
| 331 | 331 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 357 | 357 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 358 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 358 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 359 | 359 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 360 | - } else { |
|
| 360 | + } else { |
|
| 361 | 361 | 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"; |
| 362 | 362 | 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"; |
| 363 | 363 | /* |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | print_r($line); |
| 367 | 367 | */ |
| 368 | 368 | return ''; |
| 369 | - } |
|
| 369 | + } |
|
| 370 | 370 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 371 | 371 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 372 | 372 | return ''; |
@@ -382,21 +382,21 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 386 | 386 | } |
| 387 | 387 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 389 | 389 | } |
| 390 | 390 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 391 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 391 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 392 | 392 | } |
| 393 | 393 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | 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'])) { |
| 398 | 398 | |
| 399 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 399 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 400 | 400 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 401 | 401 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 402 | 402 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -405,23 +405,23 @@ discard block |
||
| 405 | 405 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 406 | 406 | 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'])); |
| 407 | 407 | } else { |
| 408 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 409 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 408 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 409 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 410 | 410 | $timeelapsed = microtime(true); |
| 411 | - $Spotter = new Spotter($this->db); |
|
| 412 | - $fromsource = NULL; |
|
| 413 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 414 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 411 | + $Spotter = new Spotter($this->db); |
|
| 412 | + $fromsource = NULL; |
|
| 413 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 414 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 415 | 415 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 416 | 416 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 417 | 417 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 418 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 418 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 419 | 419 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 420 | 420 | $Spotter->db = null; |
| 421 | 421 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 422 | - } |
|
| 422 | + } |
|
| 423 | 423 | } |
| 424 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 424 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 425 | 425 | |
| 426 | 426 | /* |
| 427 | 427 | if (!isset($line['id'])) { |
@@ -431,63 +431,63 @@ discard block |
||
| 431 | 431 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 432 | 432 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 433 | 433 | */ |
| 434 | - 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'])); |
|
| 434 | + 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'])); |
|
| 435 | 435 | |
| 436 | - //$putinarchive = true; |
|
| 437 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 436 | + //$putinarchive = true; |
|
| 437 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 438 | 438 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 439 | - } |
|
| 440 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 439 | + } |
|
| 440 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 441 | 441 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 442 | - } |
|
| 443 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 444 | - $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' => '')); |
|
| 445 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 442 | + } |
|
| 443 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 444 | + $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' => '')); |
|
| 445 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 446 | 446 | $timeelapsed = microtime(true); |
| 447 | 447 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 448 | 448 | $Spotter = new Spotter($this->db); |
| 449 | 449 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 450 | 450 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 451 | - $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' => '')); |
|
| 451 | + $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' => '')); |
|
| 452 | 452 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 453 | - } |
|
| 454 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 453 | + } |
|
| 454 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 455 | 455 | $timeelapsed = microtime(true); |
| 456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 457 | - $Spotter = new Spotter($this->db); |
|
| 458 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 459 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 457 | + $Spotter = new Spotter($this->db); |
|
| 458 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 459 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 460 | 460 | $Translation = new Translation($this->db); |
| 461 | 461 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
| 462 | 462 | $route = $Spotter->getRouteInfo($ident); |
| 463 | 463 | $Translation->db = null; |
| 464 | - } |
|
| 465 | - $Spotter->db = null; |
|
| 466 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 467 | - } |
|
| 464 | + } |
|
| 465 | + $Spotter->db = null; |
|
| 466 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 467 | + } |
|
| 468 | 468 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 469 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 470 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 469 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 470 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 471 | 471 | // $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'])); |
| 472 | - $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'])); |
|
| 473 | - } |
|
| 472 | + $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'])); |
|
| 473 | + } |
|
| 474 | 474 | } |
| 475 | 475 | if (!isset($globalFork)) $globalFork = TRUE; |
| 476 | 476 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 477 | 477 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 478 | 478 | } |
| 479 | - } |
|
| 479 | + } |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 483 | 483 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 484 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 485 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 486 | - //$dataFound = true; |
|
| 484 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 485 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 486 | + //$dataFound = true; |
|
| 487 | 487 | } 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'])) { |
| 488 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 489 | - if ($distance > 1000 && $distance < 10000) { |
|
| 490 | - // use datetime |
|
| 488 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 489 | + if ($distance > 1000 && $distance < 10000) { |
|
| 490 | + // use datetime |
|
| 491 | 491 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 492 | 492 | $speed = $speed*3.6; |
| 493 | 493 | if ($speed < 1000) { |
@@ -496,49 +496,49 @@ discard block |
||
| 496 | 496 | } else { |
| 497 | 497 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 498 | 498 | } |
| 499 | - } |
|
| 499 | + } |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | |
| 504 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 505 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 506 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 507 | - return false; |
|
| 508 | - } |
|
| 509 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 510 | - else unset($timediff); |
|
| 511 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 512 | - else unset($timediff_archive); |
|
| 513 | - if ($this->tmd > 5 |
|
| 514 | - || (isset($line['format_source']) |
|
| 515 | - && $line['format_source'] == 'airwhere' |
|
| 516 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
| 517 | - || !isset($this->all_flights[$id]['longitude'])) |
|
| 518 | - || (isset($this->all_flights[$id]['latitude']) |
|
| 519 | - && isset($this->all_flights[$id]['longitude']) |
|
| 520 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 521 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 522 | - ) |
|
| 523 | - ) |
|
| 524 | - ) |
|
| 525 | - || (isset($globalVA) && $globalVA) |
|
| 526 | - || (isset($globalIVAO) && $globalIVAO) |
|
| 527 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
| 528 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
| 529 | - || (isset($globalVAM) && $globalVAM) |
|
| 530 | - || !isset($timediff) |
|
| 531 | - || $timediff > $globalLiveInterval |
|
| 532 | - || $globalArchive |
|
| 533 | - || ($timediff > 30 |
|
| 534 | - && isset($this->all_flights[$id]['latitude']) |
|
| 535 | - && isset($this->all_flights[$id]['longitude']) |
|
| 536 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 537 | - ) |
|
| 538 | - ) { |
|
| 504 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 505 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 506 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 507 | + return false; |
|
| 508 | + } |
|
| 509 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 510 | + else unset($timediff); |
|
| 511 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 512 | + else unset($timediff_archive); |
|
| 513 | + if ($this->tmd > 5 |
|
| 514 | + || (isset($line['format_source']) |
|
| 515 | + && $line['format_source'] == 'airwhere' |
|
| 516 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
| 517 | + || !isset($this->all_flights[$id]['longitude'])) |
|
| 518 | + || (isset($this->all_flights[$id]['latitude']) |
|
| 519 | + && isset($this->all_flights[$id]['longitude']) |
|
| 520 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 521 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 522 | + ) |
|
| 523 | + ) |
|
| 524 | + ) |
|
| 525 | + || (isset($globalVA) && $globalVA) |
|
| 526 | + || (isset($globalIVAO) && $globalIVAO) |
|
| 527 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
| 528 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
| 529 | + || (isset($globalVAM) && $globalVAM) |
|
| 530 | + || !isset($timediff) |
|
| 531 | + || $timediff > $globalLiveInterval |
|
| 532 | + || $globalArchive |
|
| 533 | + || ($timediff > 30 |
|
| 534 | + && isset($this->all_flights[$id]['latitude']) |
|
| 535 | + && isset($this->all_flights[$id]['longitude']) |
|
| 536 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 537 | + ) |
|
| 538 | + ) { |
|
| 539 | 539 | |
| 540 | 540 | 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']))) { |
| 541 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 541 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 542 | 542 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 543 | 543 | || !$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'])) { |
| 544 | 544 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | $this->all_flights[$id]['putinarchive'] = true; |
| 547 | 547 | $this->tmd = 0; |
| 548 | 548 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 549 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 550 | - $timeelapsed = microtime(true); |
|
| 551 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 549 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 550 | + $timeelapsed = microtime(true); |
|
| 551 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 552 | 552 | $Spotter = new Spotter($this->db); |
| 553 | 553 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 554 | 554 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -556,11 +556,11 @@ discard block |
||
| 556 | 556 | $Spotter->db = null; |
| 557 | 557 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 558 | 558 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 559 | - } |
|
| 559 | + } |
|
| 560 | 560 | } |
| 561 | 561 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
| 562 | - } |
|
| 563 | - /* |
|
| 562 | + } |
|
| 563 | + /* |
|
| 564 | 564 | else { |
| 565 | 565 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
| 566 | 566 | else { |
@@ -574,16 +574,16 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 577 | - //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) { |
|
| 577 | + //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) { |
|
| 578 | 578 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
| 579 | 579 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 580 | 580 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 581 | 581 | } |
| 582 | 582 | //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)) { |
| 583 | 583 | 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)) { |
| 584 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 585 | - $dataFound = true; |
|
| 586 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 584 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 585 | + $dataFound = true; |
|
| 586 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 587 | 587 | } |
| 588 | 588 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 589 | 589 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -594,24 +594,24 @@ discard block |
||
| 594 | 594 | //$putinarchive = true; |
| 595 | 595 | } |
| 596 | 596 | */ |
| 597 | - /* |
|
| 597 | + /* |
|
| 598 | 598 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 599 | 599 | 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"; |
| 600 | 600 | } |
| 601 | 601 | */ |
| 602 | 602 | } |
| 603 | 603 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 604 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 605 | - //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) { |
|
| 604 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 605 | + //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) { |
|
| 606 | 606 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 607 | 607 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 608 | 608 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 609 | 609 | } |
| 610 | 610 | //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)) { |
| 611 | 611 | 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)) { |
| 612 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 613 | - $dataFound = true; |
|
| 614 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 612 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 613 | + $dataFound = true; |
|
| 614 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 615 | 615 | } |
| 616 | 616 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 617 | 617 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -629,67 +629,67 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - } else if ($globalDebug && $timediff > 30) { |
|
| 632 | + } else if ($globalDebug && $timediff > 30) { |
|
| 633 | 633 | $this->tmd = $this->tmd + 1; |
| 634 | 634 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 635 | 635 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 636 | 636 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 637 | 637 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 638 | - } |
|
| 638 | + } |
|
| 639 | 639 | } |
| 640 | 640 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 641 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 641 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 643 | 643 | } |
| 644 | 644 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 646 | - //$dataFound = true; |
|
| 645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 646 | + //$dataFound = true; |
|
| 647 | 647 | } |
| 648 | 648 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 650 | 650 | } |
| 651 | 651 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 653 | 653 | } |
| 654 | 654 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 656 | - //$dataFound = true; |
|
| 655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 656 | + //$dataFound = true; |
|
| 657 | 657 | } |
| 658 | 658 | if (isset($line['ground']) && $line['ground'] != '') { |
| 659 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 659 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 660 | 660 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 661 | 661 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 662 | 662 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 663 | 663 | 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'))); |
| 664 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 664 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 665 | 665 | 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'])); |
| 666 | - } |
|
| 667 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 669 | - //$dataFound = true; |
|
| 666 | + } |
|
| 667 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 669 | + //$dataFound = true; |
|
| 670 | 670 | } |
| 671 | 671 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 672 | - 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'])) { |
|
| 673 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 674 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 675 | - $highlight = ''; |
|
| 676 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 677 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 678 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 679 | - if ($highlight != '') { |
|
| 672 | + 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'])) { |
|
| 673 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 674 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 675 | + $highlight = ''; |
|
| 676 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 677 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 678 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 679 | + if ($highlight != '') { |
|
| 680 | 680 | $timeelapsed = microtime(true); |
| 681 | 681 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 682 | - $Spotter = new Spotter($this->db); |
|
| 683 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 684 | - $Spotter->db = null; |
|
| 685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 682 | + $Spotter = new Spotter($this->db); |
|
| 683 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 684 | + $Spotter->db = null; |
|
| 685 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 686 | 686 | } |
| 687 | 687 | //$putinarchive = true; |
| 688 | 688 | //$highlight = ''; |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 692 | - //$dataFound = true; |
|
| 691 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 692 | + //$dataFound = true; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -700,13 +700,13 @@ discard block |
||
| 700 | 700 | $line['altitude'] = $line['altitude'] - $geoid; |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 703 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 704 | 704 | 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; |
| 705 | 705 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 706 | 706 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 707 | 707 | //$dataFound = true; |
| 708 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 709 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 708 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 709 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 710 | 710 | 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) { |
| 711 | 711 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 712 | 712 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -715,27 +715,27 @@ discard block |
||
| 715 | 715 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 716 | 716 | 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'])); |
| 717 | 717 | } |
| 718 | - } |
|
| 719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 718 | + } |
|
| 719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | if (isset($line['heading']) && $line['heading'] != '') { |
| 727 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 730 | - //$dataFound = true; |
|
| 727 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 730 | + //$dataFound = true; |
|
| 731 | 731 | } 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']) { |
| 732 | - $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']); |
|
| 733 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 734 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 735 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 732 | + $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']); |
|
| 733 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 734 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 735 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 736 | 736 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 737 | - // If not enough messages and ACARS set heading to 0 |
|
| 738 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 737 | + // If not enough messages and ACARS set heading to 0 |
|
| 738 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 739 | 739 | } |
| 740 | 740 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 741 | 741 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -748,133 +748,133 @@ discard block |
||
| 748 | 748 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 749 | 749 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 750 | 750 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 751 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 752 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 753 | - 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'])) { |
|
| 754 | - //print_r($this->all_flights); |
|
| 755 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 756 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 757 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 751 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 752 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 753 | + 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'])) { |
|
| 754 | + //print_r($this->all_flights); |
|
| 755 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 756 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 757 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 758 | 758 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 759 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 760 | - $timeelapsed = microtime(true); |
|
| 761 | - $SpotterLive = new SpotterLive($this->db); |
|
| 762 | - 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')) { |
|
| 759 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 760 | + $timeelapsed = microtime(true); |
|
| 761 | + $SpotterLive = new SpotterLive($this->db); |
|
| 762 | + 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')) { |
|
| 763 | 763 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 764 | 764 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 765 | - } elseif (isset($line['id'])) { |
|
| 765 | + } elseif (isset($line['id'])) { |
|
| 766 | 766 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 767 | 767 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 768 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 768 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 769 | 769 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 770 | 770 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 771 | - } else $recent_ident = ''; |
|
| 772 | - $SpotterLive->db=null; |
|
| 773 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 774 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 771 | + } else $recent_ident = ''; |
|
| 772 | + $SpotterLive->db=null; |
|
| 773 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 774 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 775 | 775 | } else $recent_ident = ''; |
| 776 | - } else { |
|
| 776 | + } else { |
|
| 777 | 777 | $recent_ident = ''; |
| 778 | 778 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 779 | - } |
|
| 780 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 781 | - if($recent_ident == "") |
|
| 782 | - { |
|
| 779 | + } |
|
| 780 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 781 | + if($recent_ident == "") |
|
| 782 | + { |
|
| 783 | 783 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 784 | 784 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 785 | 785 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 786 | 786 | //adds the spotter data for the archive |
| 787 | 787 | $ignoreImport = false; |
| 788 | 788 | foreach($globalAirportIgnore as $airportIgnore) { |
| 789 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 789 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 790 | 790 | $ignoreImport = true; |
| 791 | - } |
|
| 791 | + } |
|
| 792 | 792 | } |
| 793 | 793 | if (count($globalAirportAccept) > 0) { |
| 794 | - $ignoreImport = true; |
|
| 795 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 794 | + $ignoreImport = true; |
|
| 795 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 796 | 796 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 797 | - $ignoreImport = false; |
|
| 797 | + $ignoreImport = false; |
|
| 798 | + } |
|
| 798 | 799 | } |
| 799 | - } |
|
| 800 | 800 | } |
| 801 | 801 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 802 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 802 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 803 | 803 | 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)) { |
| 804 | - $ignoreImport = true; |
|
| 804 | + $ignoreImport = true; |
|
| 805 | + } |
|
| 805 | 806 | } |
| 806 | - } |
|
| 807 | 807 | } |
| 808 | 808 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 809 | - $ignoreImport = true; |
|
| 810 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 809 | + $ignoreImport = true; |
|
| 810 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 811 | 811 | 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)) { |
| 812 | - $ignoreImport = false; |
|
| 812 | + $ignoreImport = false; |
|
| 813 | + } |
|
| 813 | 814 | } |
| 814 | - } |
|
| 815 | 815 | } |
| 816 | 816 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 817 | - $ignoreImport = true; |
|
| 818 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 817 | + $ignoreImport = true; |
|
| 818 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 819 | 819 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 820 | - $ignoreImport = false; |
|
| 820 | + $ignoreImport = false; |
|
| 821 | + } |
|
| 821 | 822 | } |
| 822 | - } |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | if (!$ignoreImport) { |
| 826 | - $highlight = ''; |
|
| 827 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 828 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 829 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 830 | - 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'))); |
|
| 831 | - $timeelapsed = microtime(true); |
|
| 832 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 826 | + $highlight = ''; |
|
| 827 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 828 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 829 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 830 | + 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'))); |
|
| 831 | + $timeelapsed = microtime(true); |
|
| 832 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 833 | 833 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 834 | - $Spotter = new Spotter($this->db); |
|
| 835 | - $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']); |
|
| 836 | - $Spotter->db = null; |
|
| 837 | - if ($globalDebug) { |
|
| 834 | + $Spotter = new Spotter($this->db); |
|
| 835 | + $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']); |
|
| 836 | + $Spotter->db = null; |
|
| 837 | + if ($globalDebug) { |
|
| 838 | 838 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
| 839 | 839 | else echo 'Success'; |
| 840 | - } |
|
| 841 | - if (count($result) > 1) { |
|
| 842 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 840 | + } |
|
| 841 | + if (count($result) > 1) { |
|
| 842 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 843 | 843 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
| 844 | 844 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
| 845 | - } |
|
| 845 | + } |
|
| 846 | 846 | } |
| 847 | - } |
|
| 848 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 849 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 847 | + } |
|
| 848 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 849 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 850 | 850 | |
| 851 | - // Add source stat in DB |
|
| 852 | - $Stats = new Stats($this->db); |
|
| 853 | - if (!empty($this->stats)) { |
|
| 851 | + // Add source stat in DB |
|
| 852 | + $Stats = new Stats($this->db); |
|
| 853 | + if (!empty($this->stats)) { |
|
| 854 | 854 | if ($globalDebug) echo 'Add source stats : '; |
| 855 | - foreach($this->stats as $date => $data) { |
|
| 856 | - foreach($data as $source => $sourced) { |
|
| 857 | - //print_r($sourced); |
|
| 858 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 859 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 860 | - if (isset($sourced['msg'])) { |
|
| 861 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 862 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 863 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 864 | - unset($this->stats[$date][$source]['msg']); |
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - } |
|
| 868 | - if ($date != date('Y-m-d')) { |
|
| 869 | - unset($this->stats[$date]); |
|
| 870 | - } |
|
| 871 | - } |
|
| 872 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 855 | + foreach($this->stats as $date => $data) { |
|
| 856 | + foreach($data as $source => $sourced) { |
|
| 857 | + //print_r($sourced); |
|
| 858 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 859 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 860 | + if (isset($sourced['msg'])) { |
|
| 861 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 862 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 863 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 864 | + unset($this->stats[$date][$source]['msg']); |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + } |
|
| 868 | + if ($date != date('Y-m-d')) { |
|
| 869 | + unset($this->stats[$date]); |
|
| 870 | + } |
|
| 871 | + } |
|
| 872 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 873 | 873 | |
| 874 | - } |
|
| 875 | - $Stats->db = null; |
|
| 876 | - } |
|
| 877 | - $this->del(); |
|
| 874 | + } |
|
| 875 | + $Stats->db = null; |
|
| 876 | + } |
|
| 877 | + $this->del(); |
|
| 878 | 878 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 879 | 879 | //$ignoreImport = false; |
| 880 | 880 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -892,41 +892,41 @@ discard block |
||
| 892 | 892 | */ |
| 893 | 893 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 894 | 894 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 895 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 896 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 897 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 895 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 896 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 897 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 898 | 898 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 899 | - $SpotterLive = new SpotterLive($this->db); |
|
| 900 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 901 | - $SpotterLive->db=null; |
|
| 899 | + $SpotterLive = new SpotterLive($this->db); |
|
| 900 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 901 | + $SpotterLive->db=null; |
|
| 902 | 902 | } |
| 903 | - } |
|
| 904 | - if ($globalDebug) echo " Done\n"; |
|
| 905 | - $this->last_delete = time(); |
|
| 903 | + } |
|
| 904 | + if ($globalDebug) echo " Done\n"; |
|
| 905 | + $this->last_delete = time(); |
|
| 906 | 906 | } |
| 907 | - } else { |
|
| 907 | + } else { |
|
| 908 | 908 | 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')) { |
| 909 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 910 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 909 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 910 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 911 | 911 | } |
| 912 | 912 | if (isset($globalDaemon) && !$globalDaemon) { |
| 913 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 913 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 914 | 914 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 915 | - $Spotter = new Spotter($this->db); |
|
| 916 | - $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']); |
|
| 917 | - $Spotter->db = null; |
|
| 915 | + $Spotter = new Spotter($this->db); |
|
| 916 | + $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']); |
|
| 917 | + $Spotter->db = null; |
|
| 918 | + } |
|
| 918 | 919 | } |
| 919 | - } |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | - } |
|
| 925 | - //adds the spotter LIVE data |
|
| 926 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 927 | - //echo "\nAdd in Live !! \n"; |
|
| 928 | - //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"; |
|
| 929 | - if ($globalDebug) { |
|
| 924 | + } |
|
| 925 | + //adds the spotter LIVE data |
|
| 926 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 927 | + //echo "\nAdd in Live !! \n"; |
|
| 928 | + //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"; |
|
| 929 | + if ($globalDebug) { |
|
| 930 | 930 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 931 | 931 | 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"; |
| 932 | 932 | 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"; |
@@ -934,60 +934,60 @@ discard block |
||
| 934 | 934 | 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"; |
| 935 | 935 | 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"; |
| 936 | 936 | } |
| 937 | - } |
|
| 938 | - $ignoreImport = false; |
|
| 939 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 940 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 937 | + } |
|
| 938 | + $ignoreImport = false; |
|
| 939 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 940 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 941 | 941 | |
| 942 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 943 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 944 | - $ignoreImport = true; |
|
| 942 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 943 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 944 | + $ignoreImport = true; |
|
| 945 | + } |
|
| 945 | 946 | } |
| 946 | - } |
|
| 947 | - if (count($globalAirportAccept) > 0) { |
|
| 948 | - $ignoreImport = true; |
|
| 949 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 950 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 947 | + if (count($globalAirportAccept) > 0) { |
|
| 948 | + $ignoreImport = true; |
|
| 949 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 950 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 951 | 951 | $ignoreImport = false; |
| 952 | - } |
|
| 952 | + } |
|
| 953 | 953 | } |
| 954 | - } |
|
| 955 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 954 | + } |
|
| 955 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 956 | 956 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 957 | - 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)) { |
|
| 957 | + 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)) { |
|
| 958 | 958 | $ignoreImport = true; |
| 959 | - } |
|
| 959 | + } |
|
| 960 | 960 | } |
| 961 | - } |
|
| 962 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 961 | + } |
|
| 962 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 963 | 963 | $ignoreImport = true; |
| 964 | 964 | foreach($globalAirlineAccept as $airlineAccept) { |
| 965 | - 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)) { |
|
| 965 | + 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)) { |
|
| 966 | 966 | $ignoreImport = false; |
| 967 | - } |
|
| 967 | + } |
|
| 968 | + } |
|
| 968 | 969 | } |
| 969 | - } |
|
| 970 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 970 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 971 | 971 | $ignoreImport = true; |
| 972 | 972 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 973 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 974 | - $ignoreImport = false; |
|
| 975 | - } |
|
| 973 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 974 | + $ignoreImport = false; |
|
| 975 | + } |
|
| 976 | + } |
|
| 976 | 977 | } |
| 977 | - } |
|
| 978 | 978 | |
| 979 | - if (!$ignoreImport) { |
|
| 979 | + if (!$ignoreImport) { |
|
| 980 | 980 | 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'])) { |
| 981 | 981 | 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'))); |
| 982 | 982 | $timeelapsed = microtime(true); |
| 983 | 983 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 984 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 984 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 985 | 985 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 986 | 986 | $SpotterLive = new SpotterLive($this->db); |
| 987 | 987 | $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']); |
| 988 | 988 | $SpotterLive->db = null; |
| 989 | 989 | if ($globalDebug) echo $result."\n"; |
| 990 | - } |
|
| 990 | + } |
|
| 991 | 991 | } |
| 992 | 992 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 993 | 993 | $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']); |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | //if ($line['format_source'] != 'aprs') { |
| 1000 | 1000 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 1001 | 1001 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1002 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1002 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1003 | 1003 | $source = $this->all_flights[$id]['source_name']; |
| 1004 | 1004 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
| 1005 | 1005 | if (!isset($this->source_location[$source])) { |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | if ($stats_heading == 16) $stats_heading = 0; |
| 1026 | 1026 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1027 | 1027 | for ($i=0;$i<=15;$i++) { |
| 1028 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1028 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1029 | 1029 | } |
| 1030 | 1030 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 1031 | 1031 | } else { |
@@ -1038,17 +1038,17 @@ discard block |
||
| 1038 | 1038 | //var_dump($this->stats); |
| 1039 | 1039 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1040 | 1040 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1041 | - end($this->stats[$current_date][$source]['hist']); |
|
| 1042 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1041 | + end($this->stats[$current_date][$source]['hist']); |
|
| 1042 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1043 | 1043 | } else $mini = 0; |
| 1044 | 1044 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1045 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1045 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1046 | 1046 | } |
| 1047 | 1047 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 1048 | 1048 | } else { |
| 1049 | 1049 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
| 1050 | 1050 | } |
| 1051 | - } |
|
| 1051 | + } |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | //$this->del(); |
| 1059 | 1059 | |
| 1060 | 1060 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1061 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1061 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1062 | 1062 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
| 1063 | 1063 | $SpotterLive = new SpotterLive($this->db); |
| 1064 | 1064 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1066,19 +1066,19 @@ discard block |
||
| 1066 | 1066 | //SpotterLive->deleteLiveSpotterData(); |
| 1067 | 1067 | if ($globalDebug) echo " Done\n"; |
| 1068 | 1068 | $this->last_delete_hourly = time(); |
| 1069 | - } else { |
|
| 1069 | + } else { |
|
| 1070 | 1070 | $this->del(); |
| 1071 | 1071 | $this->last_delete_hourly = time(); |
| 1072 | - } |
|
| 1072 | + } |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - } |
|
| 1076 | - //$ignoreImport = false; |
|
| 1075 | + } |
|
| 1076 | + //$ignoreImport = false; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1079 | 1079 | if ($send) return $this->all_flights[$id]; |
| 1080 | - } |
|
| 1080 | + } |
|
| 1081 | + } |
|
| 1081 | 1082 | } |
| 1082 | - } |
|
| 1083 | 1083 | } |
| 1084 | 1084 | ?> |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | $currentdate = date('Y-m-d'); |
| 35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 36 | 36 | if (!empty($sourcestat)) { |
| 37 | - foreach($sourcestat as $srcst) { |
|
| 37 | + foreach ($sourcestat as $srcst) { |
|
| 38 | 38 | $type = $srcst['stats_type']; |
| 39 | 39 | if ($type == 'polar' || $type == 'hist') { |
| 40 | 40 | $source = $srcst['source_name']; |
| 41 | 41 | $data = $srcst['source_data']; |
| 42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
| 52 | 52 | try { |
| 53 | 53 | $GeoidClass = new GeoidHeight(); |
| 54 | - } catch(Exception $e) { |
|
| 54 | + } catch (Exception $e) { |
|
| 55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
| 56 | 56 | $GeoidClass = FALSE; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function get_Schedule($id,$ident) { |
|
| 61 | + public function get_Schedule($id, $ident) { |
|
| 62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 63 | 63 | // Get schedule here, so it's done only one time |
| 64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | 88 | // Should also check if route schedule = route from DB |
| 89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
| 90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - $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']); |
|
| 107 | + $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']); |
|
| 108 | 108 | } |
| 109 | 109 | } else $scheduleexist = true; |
| 110 | 110 | } else $scheduleexist = true; |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | if ($scheduleexist) { |
| 113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 114 | 114 | $sch = $Schedule->getSchedule($operator); |
| 115 | - $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'])); |
|
| 116 | - 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']); |
|
| 115 | + $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'])); |
|
| 116 | + 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']); |
|
| 117 | 117 | } |
| 118 | 118 | $Spotter->db = null; |
| 119 | 119 | $Schedule->db = null; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 141 | 141 | $Spotter = new Spotter($this->db); |
| 142 | 142 | $real_arrival = $this->arrival($key); |
| 143 | - 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']); |
|
| 143 | + 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']); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $airport_time = ''; |
| 155 | 155 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 156 | 156 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 157 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 157 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 158 | 158 | if (isset($closestAirports[0])) { |
| 159 | 159 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 160 | 160 | $airport_icao = $closestAirports[0]['icao']; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - } 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))) { |
|
| 172 | + } 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))) { |
|
| 173 | 173 | $airport_icao = $closestAirports[0]['icao']; |
| 174 | 174 | $airport_time = $this->all_flights[$key]['datetime']; |
| 175 | 175 | } else { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } else { |
| 183 | 183 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 184 | 184 | } |
| 185 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 185 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 194 | 194 | foreach ($this->all_flights as $key => $flight) { |
| 195 | 195 | if (isset($flight['lastupdate'])) { |
| 196 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
| 196 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
| 197 | 197 | $this->delKey($key); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | $Spotter = new Spotter($this->db); |
| 211 | 211 | $SpotterLive = new SpotterLive($this->db); |
| 212 | 212 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 213 | - $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']); |
|
| 213 | + $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']); |
|
| 214 | 214 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 215 | 215 | $this->all_flights[$key]['putinarchive'] = true; |
| 216 | - $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']); |
|
| 216 | + $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']); |
|
| 217 | 217 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 218 | 218 | } |
| 219 | 219 | $Spotter->db = null; |
@@ -248,10 +248,10 @@ discard block |
||
| 248 | 248 | $send = false; |
| 249 | 249 | |
| 250 | 250 | // SBS format is CSV format |
| 251 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 251 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 252 | 252 | //print_r($line); |
| 253 | 253 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 254 | - 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)) { |
|
| 254 | + 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)) { |
|
| 255 | 255 | |
| 256 | 256 | // Increment message number |
| 257 | 257 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -284,25 +284,25 @@ discard block |
||
| 284 | 284 | if (!isset($this->all_flights[$id])) { |
| 285 | 285 | if ($globalDebug) echo 'New flight...'."\n"; |
| 286 | 286 | $this->all_flights[$id] = array(); |
| 287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 288 | - $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' => '')); |
|
| 289 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 288 | + $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' => '')); |
|
| 289 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 290 | 290 | if (!isset($line['id'])) { |
| 291 | 291 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 292 | 292 | // 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'))); |
| 293 | 293 | // 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'))); |
| 294 | - 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'))); |
|
| 294 | + 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'))); |
|
| 295 | 295 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 296 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 296 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 297 | 297 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 298 | 298 | } |
| 299 | 299 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 300 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 300 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | //print_r($this->all_flights); |
| 304 | 304 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 305 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 305 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 306 | 306 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 307 | 307 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 308 | 308 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -311,20 +311,20 @@ discard block |
||
| 311 | 311 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 312 | 312 | $Spotter = new Spotter($this->db); |
| 313 | 313 | if (isset($this->all_flights[$id]['source_type'])) { |
| 314 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 314 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 315 | 315 | } else { |
| 316 | 316 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 317 | 317 | } |
| 318 | 318 | $Spotter->db = null; |
| 319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 320 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 319 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 320 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 324 | 324 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 325 | 325 | } |
| 326 | 326 | if (isset($line['id']) && !isset($line['hex'])) { |
| 327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 328 | 328 | } |
| 329 | 329 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 330 | 330 | $icao = $line['aircraft_icao']; |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 334 | 334 | $Spotter->db = null; |
| 335 | 335 | } |
| 336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 337 | 337 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 338 | 338 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 339 | 339 | // Get aircraft ICAO from aircraft name |
| 340 | 340 | $Spotter = new Spotter($this->db); |
| 341 | 341 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 342 | 342 | $Spotter->db = null; |
| 343 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 343 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -348,15 +348,15 @@ discard block |
||
| 348 | 348 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 349 | 349 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 350 | 350 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 351 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 351 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 352 | 352 | } |
| 353 | 353 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 355 | 355 | } |
| 356 | 356 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 357 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 357 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 358 | 358 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 359 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 359 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 360 | 360 | } else { |
| 361 | 361 | 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"; |
| 362 | 362 | 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"; |
@@ -367,31 +367,31 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | return ''; |
| 369 | 369 | } |
| 370 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 370 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 371 | 371 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 372 | 372 | return ''; |
| 373 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 373 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 374 | 374 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 375 | 375 | return ''; |
| 376 | 376 | } elseif (!isset($line['datetime'])) { |
| 377 | 377 | date_default_timezone_set('UTC'); |
| 378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 379 | 379 | } else { |
| 380 | 380 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 381 | 381 | return ''; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 386 | 386 | } |
| 387 | 387 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 389 | 389 | } |
| 390 | 390 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 391 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 391 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 392 | 392 | } |
| 393 | 393 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | 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'])) { |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 400 | 400 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 401 | 401 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 404 | - 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'))); |
|
| 405 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 406 | - 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'])); |
|
| 402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 404 | + 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'))); |
|
| 405 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 406 | + 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'])); |
|
| 407 | 407 | } else { |
| 408 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 408 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 409 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 410 | 410 | $timeelapsed = microtime(true); |
| 411 | 411 | $Spotter = new Spotter($this->db); |
@@ -415,13 +415,13 @@ discard block |
||
| 415 | 415 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 416 | 416 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 417 | 417 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 418 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 418 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 419 | 419 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 420 | 420 | $Spotter->db = null; |
| 421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 421 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 424 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 425 | 425 | |
| 426 | 426 | /* |
| 427 | 427 | if (!isset($line['id'])) { |
@@ -431,25 +431,25 @@ discard block |
||
| 431 | 431 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 432 | 432 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 433 | 433 | */ |
| 434 | - 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'])); |
|
| 434 | + 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'])); |
|
| 435 | 435 | |
| 436 | 436 | //$putinarchive = true; |
| 437 | 437 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 439 | 439 | } |
| 440 | 440 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 441 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 441 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 442 | 442 | } |
| 443 | 443 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 444 | - $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' => '')); |
|
| 444 | + $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' => '')); |
|
| 445 | 445 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 446 | 446 | $timeelapsed = microtime(true); |
| 447 | 447 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 448 | 448 | $Spotter = new Spotter($this->db); |
| 449 | 449 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 450 | 450 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 451 | - $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' => '')); |
|
| 452 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 451 | + $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' => '')); |
|
| 452 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 453 | 453 | } |
| 454 | 454 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 455 | 455 | $timeelapsed = microtime(true); |
@@ -463,35 +463,35 @@ discard block |
||
| 463 | 463 | $Translation->db = null; |
| 464 | 464 | } |
| 465 | 465 | $Spotter->db = null; |
| 466 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 466 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 467 | 467 | } |
| 468 | 468 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 469 | 469 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 470 | 470 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 471 | 471 | // $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'])); |
| 472 | - $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'])); |
|
| 472 | + $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'])); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | if (!isset($globalFork)) $globalFork = TRUE; |
| 476 | 476 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 477 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 477 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 483 | 483 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 484 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 485 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 484 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 485 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 486 | 486 | //$dataFound = true; |
| 487 | 487 | } 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'])) { |
| 488 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 488 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 489 | 489 | if ($distance > 1000 && $distance < 10000) { |
| 490 | 490 | // use datetime |
| 491 | 491 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 492 | 492 | $speed = $speed*3.6; |
| 493 | 493 | if ($speed < 1000) { |
| 494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 495 | 495 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 496 | 496 | } else { |
| 497 | 497 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -506,9 +506,9 @@ discard block |
||
| 506 | 506 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 507 | 507 | return false; |
| 508 | 508 | } |
| 509 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 509 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 510 | 510 | else unset($timediff); |
| 511 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 511 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 512 | 512 | else unset($timediff_archive); |
| 513 | 513 | if ($this->tmd > 5 |
| 514 | 514 | || (isset($line['format_source']) |
@@ -533,14 +533,14 @@ discard block |
||
| 533 | 533 | || ($timediff > 30 |
| 534 | 534 | && isset($this->all_flights[$id]['latitude']) |
| 535 | 535 | && isset($this->all_flights[$id]['longitude']) |
| 536 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 536 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 537 | 537 | ) |
| 538 | 538 | ) { |
| 539 | 539 | |
| 540 | 540 | 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']))) { |
| 541 | 541 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 542 | 542 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 543 | - || !$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'])) { |
|
| 543 | + || !$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'])) { |
|
| 544 | 544 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 545 | 545 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 546 | 546 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -550,11 +550,11 @@ discard block |
||
| 550 | 550 | $timeelapsed = microtime(true); |
| 551 | 551 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 552 | 552 | $Spotter = new Spotter($this->db); |
| 553 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 553 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 554 | 554 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 555 | 555 | else $this->all_flights[$id]['over_country'] = ''; |
| 556 | 556 | $Spotter->db = null; |
| 557 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 557 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 558 | 558 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -580,13 +580,13 @@ discard block |
||
| 580 | 580 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 581 | 581 | } |
| 582 | 582 | //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)) { |
| 583 | - 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)) { |
|
| 583 | + 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)) { |
|
| 584 | 584 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 585 | 585 | $dataFound = true; |
| 586 | 586 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 587 | 587 | } |
| 588 | 588 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 589 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 589 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 590 | 590 | /* |
| 591 | 591 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 592 | 592 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -608,13 +608,13 @@ discard block |
||
| 608 | 608 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 609 | 609 | } |
| 610 | 610 | //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)) { |
| 611 | - 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)) { |
|
| 611 | + 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)) { |
|
| 612 | 612 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 613 | 613 | $dataFound = true; |
| 614 | 614 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 615 | 615 | } |
| 616 | 616 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 617 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 617 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 618 | 618 | /* |
| 619 | 619 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 620 | 620 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -632,46 +632,46 @@ discard block |
||
| 632 | 632 | } else if ($globalDebug && $timediff > 30) { |
| 633 | 633 | $this->tmd = $this->tmd + 1; |
| 634 | 634 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 635 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 636 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 635 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 636 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 637 | 637 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 641 | 641 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 643 | 643 | } |
| 644 | 644 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 646 | 646 | //$dataFound = true; |
| 647 | 647 | } |
| 648 | 648 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 650 | 650 | } |
| 651 | 651 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 653 | 653 | } |
| 654 | 654 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 656 | 656 | //$dataFound = true; |
| 657 | 657 | } |
| 658 | 658 | if (isset($line['ground']) && $line['ground'] != '') { |
| 659 | 659 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 660 | 660 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 662 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 663 | - 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'))); |
|
| 664 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 665 | - 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'])); |
|
| 661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 662 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 663 | + 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'))); |
|
| 664 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 665 | + 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'])); |
|
| 666 | 666 | } |
| 667 | 667 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 669 | 669 | //$dataFound = true; |
| 670 | 670 | } |
| 671 | 671 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 672 | 672 | 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'])) { |
| 673 | 673 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 674 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 674 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 675 | 675 | $highlight = ''; |
| 676 | 676 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 677 | 677 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -680,66 +680,66 @@ discard block |
||
| 680 | 680 | $timeelapsed = microtime(true); |
| 681 | 681 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 682 | 682 | $Spotter = new Spotter($this->db); |
| 683 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 683 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 684 | 684 | $Spotter->db = null; |
| 685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 685 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 686 | 686 | } |
| 687 | 687 | //$putinarchive = true; |
| 688 | 688 | //$highlight = ''; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 691 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 692 | 692 | //$dataFound = true; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 696 | 696 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
| 697 | 697 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
| 698 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
| 698 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
| 699 | 699 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
| 700 | 700 | $line['altitude'] = $line['altitude'] - $geoid; |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 704 | - 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; |
|
| 705 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 704 | + 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; |
|
| 705 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 707 | 707 | //$dataFound = true; |
| 708 | 708 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 709 | 709 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 710 | 710 | 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) { |
| 711 | 711 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 713 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 714 | - 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'))); |
|
| 715 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 716 | - 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'])); |
|
| 712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 713 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 714 | + 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'))); |
|
| 715 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 716 | + 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'])); |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | if (isset($line['heading']) && $line['heading'] != '') { |
| 727 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 727 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 730 | 730 | //$dataFound = true; |
| 731 | 731 | } 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']) { |
| 732 | - $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']); |
|
| 733 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 734 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 732 | + $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']); |
|
| 733 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 734 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 735 | 735 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
| 736 | 736 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 737 | 737 | // If not enough messages and ACARS set heading to 0 |
| 738 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 738 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 739 | 739 | } |
| 740 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 741 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 742 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 740 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 741 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 742 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 743 | 743 | |
| 744 | 744 | // print_r($this->all_flights[$id]); |
| 745 | 745 | //gets the callsign from the last hour |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 751 | 751 | $this->all_flights[$id]['lastupdate'] = time(); |
| 752 | 752 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 753 | - 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'])) { |
|
| 753 | + 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'])) { |
|
| 754 | 754 | //print_r($this->all_flights); |
| 755 | 755 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 756 | 756 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -761,61 +761,61 @@ discard block |
||
| 761 | 761 | $SpotterLive = new SpotterLive($this->db); |
| 762 | 762 | 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')) { |
| 763 | 763 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 764 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 764 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 765 | 765 | } elseif (isset($line['id'])) { |
| 766 | 766 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 767 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 767 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 768 | 768 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 769 | 769 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 770 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 770 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 771 | 771 | } else $recent_ident = ''; |
| 772 | - $SpotterLive->db=null; |
|
| 772 | + $SpotterLive->db = null; |
|
| 773 | 773 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 774 | 774 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 775 | 775 | } else $recent_ident = ''; |
| 776 | 776 | } else { |
| 777 | 777 | $recent_ident = ''; |
| 778 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 778 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 779 | 779 | } |
| 780 | 780 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 781 | - if($recent_ident == "") |
|
| 781 | + if ($recent_ident == "") |
|
| 782 | 782 | { |
| 783 | 783 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 784 | 784 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 785 | 785 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 786 | 786 | //adds the spotter data for the archive |
| 787 | 787 | $ignoreImport = false; |
| 788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 788 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 790 | 790 | $ignoreImport = true; |
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | if (count($globalAirportAccept) > 0) { |
| 794 | 794 | $ignoreImport = true; |
| 795 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 795 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 796 | 796 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 797 | 797 | $ignoreImport = false; |
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | 800 | } |
| 801 | 801 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 802 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 803 | - 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)) { |
|
| 802 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 803 | + 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)) { |
|
| 804 | 804 | $ignoreImport = true; |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 809 | 809 | $ignoreImport = true; |
| 810 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 811 | - 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)) { |
|
| 810 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 811 | + 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)) { |
|
| 812 | 812 | $ignoreImport = false; |
| 813 | 813 | } |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 817 | 817 | $ignoreImport = true; |
| 818 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 818 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 819 | 819 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 820 | 820 | $ignoreImport = false; |
| 821 | 821 | } |
@@ -827,12 +827,12 @@ discard block |
||
| 827 | 827 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 828 | 828 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 829 | 829 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 830 | - 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'))); |
|
| 830 | + 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'))); |
|
| 831 | 831 | $timeelapsed = microtime(true); |
| 832 | 832 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 833 | 833 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 834 | 834 | $Spotter = new Spotter($this->db); |
| 835 | - $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']); |
|
| 835 | + $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']); |
|
| 836 | 836 | $Spotter->db = null; |
| 837 | 837 | if ($globalDebug) { |
| 838 | 838 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
@@ -845,22 +845,22 @@ discard block |
||
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 848 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 849 | 849 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 850 | 850 | |
| 851 | 851 | // Add source stat in DB |
| 852 | 852 | $Stats = new Stats($this->db); |
| 853 | 853 | if (!empty($this->stats)) { |
| 854 | 854 | if ($globalDebug) echo 'Add source stats : '; |
| 855 | - foreach($this->stats as $date => $data) { |
|
| 856 | - foreach($data as $source => $sourced) { |
|
| 855 | + foreach ($this->stats as $date => $data) { |
|
| 856 | + foreach ($data as $source => $sourced) { |
|
| 857 | 857 | //print_r($sourced); |
| 858 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 859 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 858 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 859 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 860 | 860 | if (isset($sourced['msg'])) { |
| 861 | 861 | if (time() - $sourced['msg']['date'] > 10) { |
| 862 | 862 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 863 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 863 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 864 | 864 | unset($this->stats[$date][$source]['msg']); |
| 865 | 865 | } |
| 866 | 866 | } |
@@ -898,14 +898,14 @@ discard block |
||
| 898 | 898 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 899 | 899 | $SpotterLive = new SpotterLive($this->db); |
| 900 | 900 | $SpotterLive->deleteLiveSpotterData(); |
| 901 | - $SpotterLive->db=null; |
|
| 901 | + $SpotterLive->db = null; |
|
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | if ($globalDebug) echo " Done\n"; |
| 905 | 905 | $this->last_delete = time(); |
| 906 | 906 | } |
| 907 | 907 | } else { |
| 908 | - 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')) { |
|
| 908 | + 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')) { |
|
| 909 | 909 | $this->all_flights[$id]['id'] = $recent_ident; |
| 910 | 910 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 911 | 911 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 914 | 914 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 915 | 915 | $Spotter = new Spotter($this->db); |
| 916 | - $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']); |
|
| 916 | + $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']); |
|
| 917 | 917 | $Spotter->db = null; |
| 918 | 918 | } |
| 919 | 919 | } |
@@ -939,37 +939,37 @@ discard block |
||
| 939 | 939 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 940 | 940 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 941 | 941 | |
| 942 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 942 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 943 | 943 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 944 | 944 | $ignoreImport = true; |
| 945 | 945 | } |
| 946 | 946 | } |
| 947 | 947 | if (count($globalAirportAccept) > 0) { |
| 948 | 948 | $ignoreImport = true; |
| 949 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 949 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 950 | 950 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 951 | 951 | $ignoreImport = false; |
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 956 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 957 | - 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)) { |
|
| 956 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 957 | + 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)) { |
|
| 958 | 958 | $ignoreImport = true; |
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | } |
| 962 | 962 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 963 | 963 | $ignoreImport = true; |
| 964 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 965 | - 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)) { |
|
| 964 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 965 | + 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)) { |
|
| 966 | 966 | $ignoreImport = false; |
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 971 | 971 | $ignoreImport = true; |
| 972 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 972 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 973 | 973 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 974 | 974 | $ignoreImport = false; |
| 975 | 975 | } |
@@ -977,23 +977,23 @@ discard block |
||
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | if (!$ignoreImport) { |
| 980 | - 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'])) { |
|
| 981 | - 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'))); |
|
| 980 | + 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'])) { |
|
| 981 | + 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'))); |
|
| 982 | 982 | $timeelapsed = microtime(true); |
| 983 | 983 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 984 | 984 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 985 | 985 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 986 | 986 | $SpotterLive = new SpotterLive($this->db); |
| 987 | - $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']); |
|
| 987 | + $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']); |
|
| 988 | 988 | $SpotterLive->db = null; |
| 989 | 989 | if ($globalDebug) echo $result."\n"; |
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 993 | - $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']); |
|
| 993 | + $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']); |
|
| 994 | 994 | } |
| 995 | 995 | $this->all_flights[$id]['putinarchive'] = false; |
| 996 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 996 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 997 | 997 | |
| 998 | 998 | // Put statistics in $this->stats variable |
| 999 | 999 | //if ($line['format_source'] != 'aprs') { |
@@ -1012,19 +1012,19 @@ discard block |
||
| 1012 | 1012 | $latitude = $globalCenterLatitude; |
| 1013 | 1013 | $longitude = $globalCenterLongitude; |
| 1014 | 1014 | } |
| 1015 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 1015 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 1016 | 1016 | } else { |
| 1017 | 1017 | $latitude = $this->source_location[$source]['latitude']; |
| 1018 | 1018 | $longitude = $this->source_location[$source]['longitude']; |
| 1019 | 1019 | } |
| 1020 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1020 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1021 | 1021 | //$stats_heading = $stats_heading%22.5; |
| 1022 | 1022 | $stats_heading = round($stats_heading/22.5); |
| 1023 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1023 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1024 | 1024 | $current_date = date('Y-m-d'); |
| 1025 | 1025 | if ($stats_heading == 16) $stats_heading = 0; |
| 1026 | 1026 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1027 | - for ($i=0;$i<=15;$i++) { |
|
| 1027 | + for ($i = 0; $i <= 15; $i++) { |
|
| 1028 | 1028 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 1029 | 1029 | } |
| 1030 | 1030 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1039,9 +1039,9 @@ discard block |
||
| 1039 | 1039 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1040 | 1040 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1041 | 1041 | end($this->stats[$current_date][$source]['hist']); |
| 1042 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1042 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1043 | 1043 | } else $mini = 0; |
| 1044 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1044 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1045 | 1045 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1046 | 1046 | } |
| 1047 | 1047 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1055 | 1055 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1056 | 1056 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1057 | - } 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"; |
|
| 1057 | + } 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"; |
|
| 1058 | 1058 | //$this->del(); |
| 1059 | 1059 | |
| 1060 | 1060 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | try { |
| 53 | 53 | $GeoidClass = new GeoidHeight(); |
| 54 | 54 | } catch(Exception $e) { |
| 55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 55 | + if ($globalDebug) { |
|
| 56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 57 | + } |
|
| 56 | 58 | $GeoidClass = FALSE; |
| 57 | 59 | } |
| 58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
| 71 | 73 | $dbc = $this->db; |
| 72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
| 73 | 75 | if ($globalSchedulesFetch) { |
| 74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 76 | + if ($globalDebug) { |
|
| 77 | + echo 'Getting schedule info...'."\n"; |
|
| 78 | + } |
|
| 75 | 79 | $Spotter = new Spotter($dbc); |
| 76 | 80 | $Schedule = new Schedule($dbc); |
| 77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
| 83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 89 | + if ($globalDebug) { |
|
| 90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 91 | + } |
|
| 86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
| 91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 92 | 98 | if (trim($airport_icao) != '') { |
| 93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 100 | + if ($globalDebug) { |
|
| 101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 102 | + } |
|
| 95 | 103 | } |
| 96 | 104 | } |
| 97 | 105 | } |
@@ -100,20 +108,30 @@ discard block |
||
| 100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 101 | 109 | if (trim($airport_icao) != '') { |
| 102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 111 | + if ($globalDebug) { |
|
| 112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 113 | + } |
|
| 104 | 114 | } |
| 105 | 115 | } |
| 106 | 116 | } |
| 107 | 117 | $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']); |
| 108 | 118 | } |
| 109 | - } else $scheduleexist = true; |
|
| 110 | - } else $scheduleexist = true; |
|
| 119 | + } else { |
|
| 120 | + $scheduleexist = true; |
|
| 121 | + } |
|
| 122 | + } else { |
|
| 123 | + $scheduleexist = true; |
|
| 124 | + } |
|
| 111 | 125 | // close connection, at least one way will work ? |
| 112 | 126 | if ($scheduleexist) { |
| 113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 129 | + } |
|
| 114 | 130 | $sch = $Schedule->getSchedule($operator); |
| 115 | 131 | $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'])); |
| 116 | - 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']); |
|
| 132 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 133 | + $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 134 | + } |
|
| 117 | 135 | } |
| 118 | 136 | $Spotter->db = null; |
| 119 | 137 | $Schedule->db = null; |
@@ -133,14 +151,18 @@ discard block |
||
| 133 | 151 | |
| 134 | 152 | public function checkAll() { |
| 135 | 153 | global $globalDebug, $globalNoImport; |
| 136 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 154 | + if ($globalDebug) { |
|
| 155 | + echo "Update last seen flights data...\n"; |
|
| 156 | + } |
|
| 137 | 157 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 138 | 158 | foreach ($this->all_flights as $key => $flight) { |
| 139 | 159 | if (isset($this->all_flights[$key]['id'])) { |
| 140 | 160 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 141 | 161 | $Spotter = new Spotter($this->db); |
| 142 | 162 | $real_arrival = $this->arrival($key); |
| 143 | - 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']); |
|
| 163 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
| 164 | + $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']); |
|
| 165 | + } |
|
| 144 | 166 | } |
| 145 | 167 | } |
| 146 | 168 | } |
@@ -148,24 +170,32 @@ discard block |
||
| 148 | 170 | |
| 149 | 171 | public function arrival($key) { |
| 150 | 172 | global $globalClosestMinDist, $globalDebug; |
| 151 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 173 | + if ($globalDebug) { |
|
| 174 | + echo 'Update arrival...'."\n"; |
|
| 175 | + } |
|
| 152 | 176 | $Spotter = new Spotter($this->db); |
| 153 | 177 | $airport_icao = ''; |
| 154 | 178 | $airport_time = ''; |
| 155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 179 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 180 | + $globalClosestMinDist = 50; |
|
| 181 | + } |
|
| 156 | 182 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 157 | 183 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 158 | 184 | if (isset($closestAirports[0])) { |
| 159 | 185 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 160 | 186 | $airport_icao = $closestAirports[0]['icao']; |
| 161 | 187 | $airport_time = $this->all_flights[$key]['datetime']; |
| 162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 188 | + if ($globalDebug) { |
|
| 189 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 190 | + } |
|
| 163 | 191 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 164 | 192 | foreach ($closestAirports as $airport) { |
| 165 | 193 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 166 | 194 | $airport_icao = $airport['icao']; |
| 167 | 195 | $airport_time = $this->all_flights[$key]['datetime']; |
| 168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 196 | + if ($globalDebug) { |
|
| 197 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 198 | + } |
|
| 169 | 199 | break; |
| 170 | 200 | } |
| 171 | 201 | } |
@@ -173,14 +203,20 @@ discard block |
||
| 173 | 203 | $airport_icao = $closestAirports[0]['icao']; |
| 174 | 204 | $airport_time = $this->all_flights[$key]['datetime']; |
| 175 | 205 | } else { |
| 176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 206 | + if ($globalDebug) { |
|
| 207 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 208 | + } |
|
| 177 | 209 | } |
| 178 | 210 | } else { |
| 179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 211 | + if ($globalDebug) { |
|
| 212 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 213 | + } |
|
| 180 | 214 | } |
| 181 | 215 | |
| 182 | 216 | } else { |
| 183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 217 | + if ($globalDebug) { |
|
| 218 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 219 | + } |
|
| 184 | 220 | } |
| 185 | 221 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 186 | 222 | } |
@@ -190,7 +226,9 @@ discard block |
||
| 190 | 226 | public function del() { |
| 191 | 227 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 192 | 228 | // Delete old infos |
| 193 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 229 | + if ($globalDebug) { |
|
| 230 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 231 | + } |
|
| 194 | 232 | foreach ($this->all_flights as $key => $flight) { |
| 195 | 233 | if (isset($flight['lastupdate'])) { |
| 196 | 234 | if ($flight['lastupdate'] < (time()-1800)) { |
@@ -204,17 +242,23 @@ discard block |
||
| 204 | 242 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 205 | 243 | // Delete old infos |
| 206 | 244 | if (isset($this->all_flights[$key]['id'])) { |
| 207 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 247 | + } |
|
| 208 | 248 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 209 | 249 | $real_arrival = $this->arrival($key); |
| 210 | 250 | $Spotter = new Spotter($this->db); |
| 211 | 251 | $SpotterLive = new SpotterLive($this->db); |
| 212 | 252 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 213 | 253 | $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']); |
| 214 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 254 | + if ($globalDebug && $result != 'success') { |
|
| 255 | + echo '!!! ERROR : '.$result."\n"; |
|
| 256 | + } |
|
| 215 | 257 | $this->all_flights[$key]['putinarchive'] = true; |
| 216 | 258 | $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']); |
| 217 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 259 | + if ($globalDebug && $result != 'success') { |
|
| 260 | + echo '!!! ERROR : '.$result."\n"; |
|
| 261 | + } |
|
| 218 | 262 | } |
| 219 | 263 | $Spotter->db = null; |
| 220 | 264 | $SpotterLive->db = null; |
@@ -226,9 +270,13 @@ discard block |
||
| 226 | 270 | public function add($line) { |
| 227 | 271 | 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; |
| 228 | 272 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 229 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
| 230 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
| 231 | -/* |
|
| 273 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 274 | + $globalCoordMinChange = '0.01'; |
|
| 275 | + } |
|
| 276 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
| 277 | + $globalAircraftMaxUpdate = 3000; |
|
| 278 | + } |
|
| 279 | + /* |
|
| 232 | 280 | $Spotter = new Spotter(); |
| 233 | 281 | $dbc = $Spotter->db; |
| 234 | 282 | $SpotterLive = new SpotterLive($dbc); |
@@ -250,19 +298,28 @@ discard block |
||
| 250 | 298 | // SBS format is CSV format |
| 251 | 299 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 252 | 300 | //print_r($line); |
| 253 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 301 | + if (isset($line['hex'])) { |
|
| 302 | + $line['hex'] = strtoupper($line['hex']); |
|
| 303 | + } |
|
| 254 | 304 | 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)) { |
| 255 | 305 | |
| 256 | 306 | // Increment message number |
| 257 | 307 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 258 | 308 | $current_date = date('Y-m-d'); |
| 259 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 260 | - else $source = ''; |
|
| 261 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 309 | + if (isset($line['source_name'])) { |
|
| 310 | + $source = $line['source_name']; |
|
| 311 | + } else { |
|
| 312 | + $source = ''; |
|
| 313 | + } |
|
| 314 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 315 | + $source = $line['format_source']; |
|
| 316 | + } |
|
| 262 | 317 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 263 | 318 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 264 | 319 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 265 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 320 | + } else { |
|
| 321 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 322 | + } |
|
| 266 | 323 | } |
| 267 | 324 | |
| 268 | 325 | /* |
@@ -278,23 +335,38 @@ discard block |
||
| 278 | 335 | //$this->db = $dbc; |
| 279 | 336 | |
| 280 | 337 | //$hex = trim($line['hex']); |
| 281 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 282 | - else $id = trim($line['id']); |
|
| 338 | + if (!isset($line['id'])) { |
|
| 339 | + $id = trim($line['hex']); |
|
| 340 | + } else { |
|
| 341 | + $id = trim($line['id']); |
|
| 342 | + } |
|
| 283 | 343 | |
| 284 | 344 | if (!isset($this->all_flights[$id])) { |
| 285 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo 'New flight...'."\n"; |
|
| 347 | + } |
|
| 286 | 348 | $this->all_flights[$id] = array(); |
| 287 | 349 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 288 | 350 | $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' => '')); |
| 289 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 351 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
| 352 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 353 | + } |
|
| 290 | 354 | if (!isset($line['id'])) { |
| 291 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 292 | -// 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'))); |
|
| 355 | + if (!isset($globalDaemon)) { |
|
| 356 | + $globalDaemon = TRUE; |
|
| 357 | + } |
|
| 358 | + // 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'))); |
|
| 293 | 359 | // 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'))); |
| 294 | - 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'))); |
|
| 360 | + 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')) { |
|
| 361 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 362 | + } |
|
| 295 | 363 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 296 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 297 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 364 | + } else { |
|
| 365 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 366 | + } |
|
| 367 | + if ($globalAllFlights !== FALSE) { |
|
| 368 | + $dataFound = true; |
|
| 369 | + } |
|
| 298 | 370 | } |
| 299 | 371 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 300 | 372 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -316,12 +388,20 @@ discard block |
||
| 316 | 388 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 317 | 389 | } |
| 318 | 390 | $Spotter->db = null; |
| 319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 320 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 391 | + if ($globalDebugTimeElapsed) { |
|
| 392 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 393 | + } |
|
| 394 | + if ($aircraft_icao != '') { |
|
| 395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 396 | + } |
|
| 321 | 397 | } |
| 322 | 398 | } |
| 323 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 324 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 399 | + if ($globalAllFlights !== FALSE) { |
|
| 400 | + $dataFound = true; |
|
| 401 | + } |
|
| 402 | + if ($globalDebug) { |
|
| 403 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 404 | + } |
|
| 325 | 405 | } |
| 326 | 406 | if (isset($line['id']) && !isset($line['hex'])) { |
| 327 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -330,7 +410,9 @@ discard block |
||
| 330 | 410 | $icao = $line['aircraft_icao']; |
| 331 | 411 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 332 | 412 | $Spotter = new Spotter($this->db); |
| 333 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 413 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
| 414 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 415 | + } |
|
| 334 | 416 | $Spotter->db = null; |
| 335 | 417 | } |
| 336 | 418 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -340,15 +422,24 @@ discard block |
||
| 340 | 422 | $Spotter = new Spotter($this->db); |
| 341 | 423 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 342 | 424 | $Spotter->db = null; |
| 343 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 425 | + if ($aircraft_icao != '') { |
|
| 426 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 427 | + } |
|
| 344 | 428 | } |
| 345 | 429 | } |
| 346 | 430 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 347 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 348 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 349 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 350 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 351 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 431 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 432 | + $aircraft_icao = 'GLID'; |
|
| 433 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 434 | + $aircraft_icao = 'UHEL'; |
|
| 435 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 436 | + $aircraft_icao = 'TOWPLANE'; |
|
| 437 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 438 | + $aircraft_icao = 'POWAIRC'; |
|
| 439 | + } |
|
| 440 | + if (isset($aircraft_icao)) { |
|
| 441 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 442 | + } |
|
| 352 | 443 | } |
| 353 | 444 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 354 | 445 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -358,8 +449,11 @@ discard block |
||
| 358 | 449 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 359 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 360 | 451 | } else { |
| 361 | - 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"; |
|
| 362 | - 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"; |
|
| 452 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 453 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 454 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 455 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 456 | + } |
|
| 363 | 457 | /* |
| 364 | 458 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 365 | 459 | print_r($this->all_flights[$id]); |
@@ -368,16 +462,22 @@ discard block |
||
| 368 | 462 | return ''; |
| 369 | 463 | } |
| 370 | 464 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 371 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 465 | + if ($globalDebug) { |
|
| 466 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 467 | + } |
|
| 372 | 468 | return ''; |
| 373 | 469 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 374 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 470 | + if ($globalDebug) { |
|
| 471 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 472 | + } |
|
| 375 | 473 | return ''; |
| 376 | 474 | } elseif (!isset($line['datetime'])) { |
| 377 | 475 | date_default_timezone_set('UTC'); |
| 378 | 476 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 379 | 477 | } else { |
| 380 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 478 | + if ($globalDebug) { |
|
| 479 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 480 | + } |
|
| 381 | 481 | return ''; |
| 382 | 482 | } |
| 383 | 483 | |
@@ -398,30 +498,48 @@ discard block |
||
| 398 | 498 | |
| 399 | 499 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 400 | 500 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 401 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 501 | + if ($globalDebug) { |
|
| 502 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 503 | + } |
|
| 402 | 504 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 403 | 505 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 404 | - 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'))); |
|
| 405 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 406 | - 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'])); |
|
| 506 | + 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')) { |
|
| 507 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 508 | + } elseif (isset($line['id'])) { |
|
| 509 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 510 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 511 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 512 | + } |
|
| 407 | 513 | } else { |
| 408 | 514 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
| 409 | 515 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 410 | 516 | $timeelapsed = microtime(true); |
| 411 | 517 | $Spotter = new Spotter($this->db); |
| 412 | 518 | $fromsource = NULL; |
| 413 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 414 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 415 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 416 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 417 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 519 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 520 | + $fromsource = $globalAirlinesSource; |
|
| 521 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 522 | + $fromsource = 'vatsim'; |
|
| 523 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 524 | + $fromsource = 'ivao'; |
|
| 525 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 526 | + $fromsource = 'vatsim'; |
|
| 527 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 528 | + $fromsource = 'ivao'; |
|
| 529 | + } |
|
| 418 | 530 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
| 419 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 531 | + if ($globalDebug && $result != 'success') { |
|
| 532 | + echo '!!! ERROR : '.$result."\n"; |
|
| 533 | + } |
|
| 420 | 534 | $Spotter->db = null; |
| 421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 535 | + if ($globalDebugTimeElapsed) { |
|
| 536 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 537 | + } |
|
| 422 | 538 | } |
| 423 | 539 | } |
| 424 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 540 | + } else { |
|
| 541 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 542 | + } |
|
| 425 | 543 | |
| 426 | 544 | /* |
| 427 | 545 | if (!isset($line['id'])) { |
@@ -431,7 +549,9 @@ discard block |
||
| 431 | 549 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 432 | 550 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 433 | 551 | */ |
| 434 | - 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'])); |
|
| 552 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 553 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 554 | + } |
|
| 435 | 555 | |
| 436 | 556 | //$putinarchive = true; |
| 437 | 557 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -449,7 +569,9 @@ discard block |
||
| 449 | 569 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 450 | 570 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 451 | 571 | $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' => '')); |
| 452 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 572 | + if ($globalDebugTimeElapsed) { |
|
| 573 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 574 | + } |
|
| 453 | 575 | } |
| 454 | 576 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 455 | 577 | $timeelapsed = microtime(true); |
@@ -463,7 +585,9 @@ discard block |
||
| 463 | 585 | $Translation->db = null; |
| 464 | 586 | } |
| 465 | 587 | $Spotter->db = null; |
| 466 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 588 | + if ($globalDebugTimeElapsed) { |
|
| 589 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 590 | + } |
|
| 467 | 591 | } |
| 468 | 592 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 469 | 593 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -472,9 +596,13 @@ discard block |
||
| 472 | 596 | $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'])); |
| 473 | 597 | } |
| 474 | 598 | } |
| 475 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 599 | + if (!isset($globalFork)) { |
|
| 600 | + $globalFork = TRUE; |
|
| 601 | + } |
|
| 476 | 602 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 477 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 603 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 604 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 605 | + } |
|
| 478 | 606 | } |
| 479 | 607 | } |
| 480 | 608 | } |
@@ -492,9 +620,13 @@ discard block |
||
| 492 | 620 | $speed = $speed*3.6; |
| 493 | 621 | if ($speed < 1000) { |
| 494 | 622 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 495 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 623 | + if ($globalDebug) { |
|
| 624 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 625 | + } |
|
| 496 | 626 | } else { |
| 497 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 627 | + if ($globalDebug) { |
|
| 628 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 629 | + } |
|
| 498 | 630 | } |
| 499 | 631 | } |
| 500 | 632 | } |
@@ -503,13 +635,21 @@ discard block |
||
| 503 | 635 | |
| 504 | 636 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 505 | 637 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
| 506 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 638 | + if ($globalDebug) { |
|
| 639 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 640 | + } |
|
| 507 | 641 | return false; |
| 508 | 642 | } |
| 509 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 510 | - else unset($timediff); |
|
| 511 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 512 | - else unset($timediff_archive); |
|
| 643 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 644 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 645 | + } else { |
|
| 646 | + unset($timediff); |
|
| 647 | + } |
|
| 648 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
| 649 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 650 | + } else { |
|
| 651 | + unset($timediff_archive); |
|
| 652 | + } |
|
| 513 | 653 | if ($this->tmd > 5 |
| 514 | 654 | || (isset($line['format_source']) |
| 515 | 655 | && $line['format_source'] == 'airwhere' |
@@ -546,16 +686,25 @@ discard block |
||
| 546 | 686 | $this->all_flights[$id]['putinarchive'] = true; |
| 547 | 687 | $this->tmd = 0; |
| 548 | 688 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 549 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 689 | + if ($globalDebug) { |
|
| 690 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 691 | + } |
|
| 550 | 692 | $timeelapsed = microtime(true); |
| 551 | 693 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 552 | 694 | $Spotter = new Spotter($this->db); |
| 553 | 695 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 554 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 555 | - else $this->all_flights[$id]['over_country'] = ''; |
|
| 696 | + if (!empty($all_country)) { |
|
| 697 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 698 | + } else { |
|
| 699 | + $this->all_flights[$id]['over_country'] = ''; |
|
| 700 | + } |
|
| 556 | 701 | $Spotter->db = null; |
| 557 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 558 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 702 | + if ($globalDebugTimeElapsed) { |
|
| 703 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 704 | + } |
|
| 705 | + if ($globalDebug) { |
|
| 706 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 707 | + } |
|
| 559 | 708 | } |
| 560 | 709 | } |
| 561 | 710 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -601,7 +750,9 @@ discard block |
||
| 601 | 750 | */ |
| 602 | 751 | } |
| 603 | 752 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 604 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 753 | + if ($line['longitude'] > 180) { |
|
| 754 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 755 | + } |
|
| 605 | 756 | //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) { |
| 606 | 757 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 607 | 758 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -638,7 +789,9 @@ discard block |
||
| 638 | 789 | } |
| 639 | 790 | } |
| 640 | 791 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 641 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 792 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 793 | + $dataFound = true; |
|
| 794 | + } |
|
| 642 | 795 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 643 | 796 | } |
| 644 | 797 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -660,35 +813,53 @@ discard block |
||
| 660 | 813 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 661 | 814 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 662 | 815 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 663 | - 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'))); |
|
| 664 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 665 | - 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'])); |
|
| 816 | + 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')) { |
|
| 817 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 818 | + } elseif (isset($line['id'])) { |
|
| 819 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 820 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 821 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + if ($line['ground'] != 1) { |
|
| 825 | + $line['ground'] = 0; |
|
| 666 | 826 | } |
| 667 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 668 | 827 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 669 | 828 | //$dataFound = true; |
| 670 | 829 | } |
| 671 | 830 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 672 | 831 | 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'])) { |
| 673 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 832 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 833 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 834 | + } |
|
| 674 | 835 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 675 | 836 | $highlight = ''; |
| 676 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 677 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 678 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 837 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 838 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 839 | + } |
|
| 840 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 841 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 842 | + } |
|
| 843 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 844 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 845 | + } |
|
| 679 | 846 | if ($highlight != '') { |
| 680 | 847 | $timeelapsed = microtime(true); |
| 681 | 848 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 682 | 849 | $Spotter = new Spotter($this->db); |
| 683 | 850 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 684 | 851 | $Spotter->db = null; |
| 685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 852 | + if ($globalDebugTimeElapsed) { |
|
| 853 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 854 | + } |
|
| 686 | 855 | } |
| 687 | 856 | //$putinarchive = true; |
| 688 | 857 | //$highlight = ''; |
| 689 | 858 | } |
| 690 | 859 | |
| 691 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 860 | + } else { |
|
| 861 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 862 | + } |
|
| 692 | 863 | //$dataFound = true; |
| 693 | 864 | } |
| 694 | 865 | |
@@ -701,19 +872,27 @@ discard block |
||
| 701 | 872 | } |
| 702 | 873 | } |
| 703 | 874 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 704 | - 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; |
|
| 875 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 876 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 877 | + } |
|
| 705 | 878 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 706 | 879 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 707 | 880 | //$dataFound = true; |
| 708 | 881 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 709 | 882 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 710 | 883 | 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) { |
| 711 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
| 884 | + if ($globalDebug) { |
|
| 885 | + echo '--- Reset because of altitude'."\n"; |
|
| 886 | + } |
|
| 712 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 713 | 888 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 714 | - 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'))); |
|
| 715 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 716 | - 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'])); |
|
| 889 | + 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')) { |
|
| 890 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 891 | + } elseif (isset($line['id'])) { |
|
| 892 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 893 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 894 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 895 | + } |
|
| 717 | 896 | } |
| 718 | 897 | } |
| 719 | 898 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -724,22 +903,32 @@ discard block |
||
| 724 | 903 | } |
| 725 | 904 | |
| 726 | 905 | if (isset($line['heading']) && $line['heading'] != '') { |
| 727 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 906 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 907 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 908 | + } |
|
| 728 | 909 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 729 | 910 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 730 | 911 | //$dataFound = true; |
| 731 | 912 | } 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']) { |
| 732 | 913 | $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']); |
| 733 | 914 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 734 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 735 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 915 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 916 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 917 | + } |
|
| 918 | + if ($globalDebug) { |
|
| 919 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 920 | + } |
|
| 736 | 921 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 737 | 922 | // If not enough messages and ACARS set heading to 0 |
| 738 | 923 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 739 | 924 | } |
| 740 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 741 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 742 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 925 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 926 | + $dataFound = false; |
|
| 927 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 928 | + $dataFound = false; |
|
| 929 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
| 930 | + $dataFound = false; |
|
| 931 | + } |
|
| 743 | 932 | |
| 744 | 933 | // print_r($this->all_flights[$id]); |
| 745 | 934 | //gets the callsign from the last hour |
@@ -756,23 +945,38 @@ discard block |
||
| 756 | 945 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 757 | 946 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 758 | 947 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 759 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 948 | + if ($globalDebug) { |
|
| 949 | + echo "Check if aircraft is already in DB..."; |
|
| 950 | + } |
|
| 760 | 951 | $timeelapsed = microtime(true); |
| 761 | 952 | $SpotterLive = new SpotterLive($this->db); |
| 762 | 953 | 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')) { |
| 763 | 954 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 764 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 955 | + if ($globalDebugTimeElapsed) { |
|
| 956 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 957 | + } |
|
| 765 | 958 | } elseif (isset($line['id'])) { |
| 766 | 959 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 767 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 960 | + if ($globalDebugTimeElapsed) { |
|
| 961 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 962 | + } |
|
| 768 | 963 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 769 | 964 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 770 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 771 | - } else $recent_ident = ''; |
|
| 965 | + if ($globalDebugTimeElapsed) { |
|
| 966 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 967 | + } |
|
| 968 | + } else { |
|
| 969 | + $recent_ident = ''; |
|
| 970 | + } |
|
| 772 | 971 | $SpotterLive->db=null; |
| 773 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 774 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 775 | - } else $recent_ident = ''; |
|
| 972 | + if ($globalDebug && $recent_ident == '') { |
|
| 973 | + echo " Not in DB.\n"; |
|
| 974 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 975 | + echo " Already in DB.\n"; |
|
| 976 | + } |
|
| 977 | + } else { |
|
| 978 | + $recent_ident = ''; |
|
| 979 | + } |
|
| 776 | 980 | } else { |
| 777 | 981 | $recent_ident = ''; |
| 778 | 982 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -780,7 +984,9 @@ discard block |
||
| 780 | 984 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 781 | 985 | if($recent_ident == "") |
| 782 | 986 | { |
| 783 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 987 | + if ($globalDebug) { |
|
| 988 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 989 | + } |
|
| 784 | 990 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 785 | 991 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 786 | 992 | //adds the spotter data for the archive |
@@ -824,10 +1030,18 @@ discard block |
||
| 824 | 1030 | |
| 825 | 1031 | if (!$ignoreImport) { |
| 826 | 1032 | $highlight = ''; |
| 827 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 828 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 829 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 830 | - 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'))); |
|
| 1033 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 1034 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 1035 | + } |
|
| 1036 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 1037 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 1038 | + } |
|
| 1039 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 1040 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 1041 | + } |
|
| 1042 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1043 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1044 | + } |
|
| 831 | 1045 | $timeelapsed = microtime(true); |
| 832 | 1046 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 833 | 1047 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -835,28 +1049,43 @@ discard block |
||
| 835 | 1049 | $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']); |
| 836 | 1050 | $Spotter->db = null; |
| 837 | 1051 | if ($globalDebug) { |
| 838 | - if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
| 839 | - else echo 'Success'; |
|
| 1052 | + if (isset($result['error'])) { |
|
| 1053 | + echo 'Error: '.$result['error']."\n"; |
|
| 1054 | + } else { |
|
| 1055 | + echo 'Success'; |
|
| 1056 | + } |
|
| 840 | 1057 | } |
| 841 | 1058 | if (count($result) > 1) { |
| 842 | 1059 | // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
| 843 | - if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 844 | - if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1060 | + if ($this->all_flights[$id]['aircraft_icao'] == '') { |
|
| 1061 | + $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 1062 | + } |
|
| 1063 | + if ($this->all_flights[$id]['registration'] == '') { |
|
| 1064 | + $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1065 | + } |
|
| 845 | 1066 | } |
| 846 | 1067 | } |
| 847 | 1068 | } |
| 848 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1069 | + if ($globalDebugTimeElapsed) { |
|
| 1070 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1071 | + } |
|
| 849 | 1072 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 850 | 1073 | |
| 851 | 1074 | // Add source stat in DB |
| 852 | 1075 | $Stats = new Stats($this->db); |
| 853 | 1076 | if (!empty($this->stats)) { |
| 854 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 1077 | + if ($globalDebug) { |
|
| 1078 | + echo 'Add source stats : '; |
|
| 1079 | + } |
|
| 855 | 1080 | foreach($this->stats as $date => $data) { |
| 856 | 1081 | foreach($data as $source => $sourced) { |
| 857 | 1082 | //print_r($sourced); |
| 858 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 859 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1083 | + if (isset($sourced['polar'])) { |
|
| 1084 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 1085 | + } |
|
| 1086 | + if (isset($sourced['hist'])) { |
|
| 1087 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1088 | + } |
|
| 860 | 1089 | if (isset($sourced['msg'])) { |
| 861 | 1090 | if (time() - $sourced['msg']['date'] > 10) { |
| 862 | 1091 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -869,13 +1098,17 @@ discard block |
||
| 869 | 1098 | unset($this->stats[$date]); |
| 870 | 1099 | } |
| 871 | 1100 | } |
| 872 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1101 | + if ($globalDebug) { |
|
| 1102 | + echo 'Done'."\n"; |
|
| 1103 | + } |
|
| 873 | 1104 | |
| 874 | 1105 | } |
| 875 | 1106 | $Stats->db = null; |
| 876 | 1107 | } |
| 877 | 1108 | $this->del(); |
| 878 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 1109 | + } elseif ($globalDebug) { |
|
| 1110 | + echo 'Ignore data'."\n"; |
|
| 1111 | + } |
|
| 879 | 1112 | //$ignoreImport = false; |
| 880 | 1113 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 881 | 1114 | //print_r($this->all_flights[$id]); |
@@ -892,7 +1125,9 @@ discard block |
||
| 892 | 1125 | */ |
| 893 | 1126 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 894 | 1127 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 895 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1128 | + if ($globalDebug) { |
|
| 1129 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1130 | + } |
|
| 896 | 1131 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 897 | 1132 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 898 | 1133 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -901,7 +1136,9 @@ discard block |
||
| 901 | 1136 | $SpotterLive->db=null; |
| 902 | 1137 | } |
| 903 | 1138 | } |
| 904 | - if ($globalDebug) echo " Done\n"; |
|
| 1139 | + if ($globalDebug) { |
|
| 1140 | + echo " Done\n"; |
|
| 1141 | + } |
|
| 905 | 1142 | $this->last_delete = time(); |
| 906 | 1143 | } |
| 907 | 1144 | } else { |
@@ -928,11 +1165,17 @@ discard block |
||
| 928 | 1165 | //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"; |
| 929 | 1166 | if ($globalDebug) { |
| 930 | 1167 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 931 | - 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"; |
|
| 932 | - 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"; |
|
| 1168 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1169 | + 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"; |
|
| 1170 | + } else { |
|
| 1171 | + 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"; |
|
| 1172 | + } |
|
| 933 | 1173 | } else { |
| 934 | - 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"; |
|
| 935 | - 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"; |
|
| 1174 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1175 | + 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"; |
|
| 1176 | + } else { |
|
| 1177 | + 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"; |
|
| 1178 | + } |
|
| 936 | 1179 | } |
| 937 | 1180 | } |
| 938 | 1181 | $ignoreImport = false; |
@@ -978,22 +1221,30 @@ discard block |
||
| 978 | 1221 | |
| 979 | 1222 | if (!$ignoreImport) { |
| 980 | 1223 | 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'])) { |
| 981 | - 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'))); |
|
| 1224 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1225 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1226 | + } |
|
| 982 | 1227 | $timeelapsed = microtime(true); |
| 983 | 1228 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 984 | 1229 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 985 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1230 | + if ($globalDebug) { |
|
| 1231 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1232 | + } |
|
| 986 | 1233 | $SpotterLive = new SpotterLive($this->db); |
| 987 | 1234 | $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']); |
| 988 | 1235 | $SpotterLive->db = null; |
| 989 | - if ($globalDebug) echo $result."\n"; |
|
| 1236 | + if ($globalDebug) { |
|
| 1237 | + echo $result."\n"; |
|
| 1238 | + } |
|
| 990 | 1239 | } |
| 991 | 1240 | } |
| 992 | 1241 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 993 | 1242 | $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']); |
| 994 | 1243 | } |
| 995 | 1244 | $this->all_flights[$id]['putinarchive'] = false; |
| 996 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1245 | + if ($globalDebugTimeElapsed) { |
|
| 1246 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1247 | + } |
|
| 997 | 1248 | |
| 998 | 1249 | // Put statistics in $this->stats variable |
| 999 | 1250 | //if ($line['format_source'] != 'aprs') { |
@@ -1001,7 +1252,9 @@ discard block |
||
| 1001 | 1252 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1002 | 1253 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 1003 | 1254 | $source = $this->all_flights[$id]['source_name']; |
| 1004 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1255 | + if ($source == '') { |
|
| 1256 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1257 | + } |
|
| 1005 | 1258 | if (!isset($this->source_location[$source])) { |
| 1006 | 1259 | $Location = new Source($this->db); |
| 1007 | 1260 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1022,7 +1275,9 @@ discard block |
||
| 1022 | 1275 | $stats_heading = round($stats_heading/22.5); |
| 1023 | 1276 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 1024 | 1277 | $current_date = date('Y-m-d'); |
| 1025 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1278 | + if ($stats_heading == 16) { |
|
| 1279 | + $stats_heading = 0; |
|
| 1280 | + } |
|
| 1026 | 1281 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1027 | 1282 | for ($i=0;$i<=15;$i++) { |
| 1028 | 1283 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1040,7 +1295,9 @@ discard block |
||
| 1040 | 1295 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1041 | 1296 | end($this->stats[$current_date][$source]['hist']); |
| 1042 | 1297 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 1043 | - } else $mini = 0; |
|
| 1298 | + } else { |
|
| 1299 | + $mini = 0; |
|
| 1300 | + } |
|
| 1044 | 1301 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1045 | 1302 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1046 | 1303 | } |
@@ -1052,19 +1309,27 @@ discard block |
||
| 1052 | 1309 | } |
| 1053 | 1310 | |
| 1054 | 1311 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1055 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1312 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1313 | + $send = true; |
|
| 1314 | + } |
|
| 1056 | 1315 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1057 | - } 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"; |
|
| 1316 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1317 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1318 | + } |
|
| 1058 | 1319 | //$this->del(); |
| 1059 | 1320 | |
| 1060 | 1321 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1061 | 1322 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 1062 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1323 | + if ($globalDebug) { |
|
| 1324 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1325 | + } |
|
| 1063 | 1326 | $SpotterLive = new SpotterLive($this->db); |
| 1064 | 1327 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 1065 | 1328 | $SpotterLive->db = null; |
| 1066 | 1329 | //SpotterLive->deleteLiveSpotterData(); |
| 1067 | - if ($globalDebug) echo " Done\n"; |
|
| 1330 | + if ($globalDebug) { |
|
| 1331 | + echo " Done\n"; |
|
| 1332 | + } |
|
| 1068 | 1333 | $this->last_delete_hourly = time(); |
| 1069 | 1334 | } else { |
| 1070 | 1335 | $this->del(); |
@@ -1076,7 +1341,9 @@ discard block |
||
| 1076 | 1341 | //$ignoreImport = false; |
| 1077 | 1342 | } |
| 1078 | 1343 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1079 | - if ($send) return $this->all_flights[$id]; |
|
| 1344 | + if ($send) { |
|
| 1345 | + return $this->all_flights[$id]; |
|
| 1346 | + } |
|
| 1080 | 1347 | } |
| 1081 | 1348 | } |
| 1082 | 1349 | } |
@@ -17,62 +17,62 @@ discard block |
||
| 17 | 17 | * @param Array $filter the filter |
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 38 | 38 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
| 39 | 39 | if (isset($flt['source'])) { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | 49 | } else { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 54 | 54 | if (isset($flt['source'])) { |
| 55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | 56 | } else { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 61 | 61 | if (isset($flt['source'])) { |
| 62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | 63 | } else { |
| 64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 68 | 68 | if (isset($flt['source'])) { |
| 69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 74 | 74 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 88 | 88 | if (count($filter['source']) == 1) { |
| 89 | 89 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
| 90 | 90 | } else { |
| 91 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 91 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 124 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 125 | 125 | } |
| 126 | 126 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 127 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 127 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 128 | 128 | } |
| 129 | 129 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 130 | 130 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 131 | 131 | if ($filter_query_where != '') { |
| 132 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 132 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 133 | 133 | } |
| 134 | 134 | $filter_query = $filter_query_join.$filter_query_where; |
| 135 | 135 | return $filter_query; |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | if ($limit != '') |
| 153 | 153 | { |
| 154 | 154 | $limit_array = explode(',', $limit); |
| 155 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 156 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 155 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 156 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 157 | 157 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 158 | 158 | { |
| 159 | 159 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | } else { |
| 178 | 178 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 179 | 179 | } |
| 180 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 180 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 181 | 181 | |
| 182 | 182 | return $spotter_array; |
| 183 | 183 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 194 | 194 | date_default_timezone_set('UTC'); |
| 195 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 195 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 196 | 196 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 197 | 197 | if ($globalDBdriver == 'mysql') { |
| 198 | 198 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute(); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | echo $e->getMessage(); |
| 220 | 220 | die; |
| 221 | 221 | } |
@@ -229,20 +229,20 @@ discard block |
||
| 229 | 229 | * @return Array the spotter information |
| 230 | 230 | * |
| 231 | 231 | */ |
| 232 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '') |
|
| 232 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false, $id = '') |
|
| 233 | 233 | { |
| 234 | 234 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 235 | 235 | date_default_timezone_set('UTC'); |
| 236 | 236 | $usecoord = false; |
| 237 | 237 | if (is_array($coord) && !empty($coord)) { |
| 238 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 239 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 240 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 241 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 238 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 239 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 240 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 241 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 242 | 242 | $usecoord = true; |
| 243 | 243 | } |
| 244 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
| 245 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 244 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 245 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 246 | 246 | |
| 247 | 247 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 248 | 248 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 255 | 255 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 256 | 256 | */ |
| 257 | - $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 257 | + $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 258 | 258 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 259 | 259 | if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
| 260 | 260 | if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | ORDER BY flightaware_id, date"; |
| 269 | 269 | if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
| 270 | 270 | } else { |
| 271 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 271 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 272 | 272 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 273 | 273 | if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
| 274 | 274 | if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 285 | 285 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 286 | 286 | */ |
| 287 | - $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 287 | + $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
| 288 | 288 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 289 | 289 | if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
| 290 | 290 | if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | try { |
| 312 | 312 | $sth = $this->db->prepare($query); |
| 313 | 313 | $sth->execute($query_values); |
| 314 | - } catch(PDOException $e) { |
|
| 314 | + } catch (PDOException $e) { |
|
| 315 | 315 | echo $e->getMessage(); |
| 316 | 316 | die; |
| 317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | public function getLiveSpotterCount($filter = array()) |
| 329 | 329 | { |
| 330 | 330 | global $globalDBdriver, $globalLiveInterval; |
| 331 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 331 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 332 | 332 | |
| 333 | 333 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 334 | 334 | if ($globalDBdriver == 'mysql') { |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | try { |
| 342 | 342 | $sth = $this->db->prepare($query); |
| 343 | 343 | $sth->execute(); |
| 344 | - } catch(PDOException $e) { |
|
| 344 | + } catch (PDOException $e) { |
|
| 345 | 345 | echo $e->getMessage(); |
| 346 | 346 | die; |
| 347 | 347 | } |
@@ -364,10 +364,10 @@ discard block |
||
| 364 | 364 | $filter_query = $this->getFilter($filter); |
| 365 | 365 | |
| 366 | 366 | if (is_array($coord)) { |
| 367 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 368 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 369 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 370 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 367 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 368 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 369 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 370 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 371 | 371 | } else return array(); |
| 372 | 372 | if ($globalDBdriver == 'mysql') { |
| 373 | 373 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -390,23 +390,23 @@ discard block |
||
| 390 | 390 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 391 | 391 | $Spotter = new Spotter($this->db); |
| 392 | 392 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 393 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 393 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 394 | 394 | |
| 395 | 395 | if (is_array($coord)) { |
| 396 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 397 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 398 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 399 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 396 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 397 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 398 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 399 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 400 | 400 | } else return array(); |
| 401 | 401 | if ($globalDBdriver == 'mysql') { |
| 402 | 402 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 403 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 403 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 404 | 404 | FROM spotter_live |
| 405 | 405 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 406 | 406 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 407 | 407 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC'; |
| 408 | 408 | } else { |
| 409 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 409 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 410 | 410 | FROM spotter_live |
| 411 | 411 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 412 | 412 | FROM spotter_live l |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | } else { |
| 420 | 420 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 421 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 421 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 422 | 422 | FROM spotter_live |
| 423 | 423 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 424 | 424 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 425 | 425 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 426 | 426 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 427 | 427 | } else { |
| 428 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 428 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 429 | 429 | FROM spotter_live |
| 430 | 430 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 431 | 431 | FROM spotter_live l |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | try { |
| 441 | 441 | $sth = $this->db->prepare($query); |
| 442 | 442 | $sth->execute(); |
| 443 | - } catch(PDOException $e) { |
|
| 443 | + } catch (PDOException $e) { |
|
| 444 | 444 | echo $e->getMessage(); |
| 445 | 445 | die; |
| 446 | 446 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | if ($interval == '1m') |
| 490 | 490 | { |
| 491 | 491 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 492 | - } else if ($interval == '15m'){ |
|
| 492 | + } else if ($interval == '15m') { |
|
| 493 | 493 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 494 | 494 | } |
| 495 | 495 | } |
@@ -497,14 +497,14 @@ discard block |
||
| 497 | 497 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 500 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 501 | 501 | WHERE spotter_live.latitude <> '' |
| 502 | 502 | AND spotter_live.longitude <> '' |
| 503 | 503 | ".$additional_query." |
| 504 | 504 | HAVING distance < :radius |
| 505 | 505 | ORDER BY distance"; |
| 506 | 506 | |
| 507 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 507 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 508 | 508 | |
| 509 | 509 | return $spotter_array; |
| 510 | 510 | } |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | date_default_timezone_set('UTC'); |
| 523 | 523 | |
| 524 | 524 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 525 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 525 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 526 | 526 | |
| 527 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 527 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 528 | 528 | |
| 529 | 529 | return $spotter_array; |
| 530 | 530 | } |
@@ -535,16 +535,16 @@ discard block |
||
| 535 | 535 | * @return Array the spotter information |
| 536 | 536 | * |
| 537 | 537 | */ |
| 538 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 538 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 539 | 539 | { |
| 540 | 540 | $Spotter = new Spotter($this->db); |
| 541 | 541 | date_default_timezone_set('UTC'); |
| 542 | 542 | |
| 543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 544 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 544 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 545 | 545 | |
| 546 | - $date = date('c',$date); |
|
| 547 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 546 | + $date = date('c', $date); |
|
| 547 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 548 | 548 | |
| 549 | 549 | return $spotter_array; |
| 550 | 550 | } |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | $Spotter = new Spotter($this->db); |
| 561 | 561 | date_default_timezone_set('UTC'); |
| 562 | 562 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 563 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 564 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 563 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 564 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 565 | 565 | return $spotter_array; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -571,15 +571,15 @@ discard block |
||
| 571 | 571 | * @return Array the spotter information |
| 572 | 572 | * |
| 573 | 573 | */ |
| 574 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 574 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 575 | 575 | { |
| 576 | 576 | $Spotter = new Spotter($this->db); |
| 577 | 577 | date_default_timezone_set('UTC'); |
| 578 | 578 | |
| 579 | 579 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 580 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 581 | - $date = date('c',$date); |
|
| 582 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 580 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 581 | + $date = date('c', $date); |
|
| 582 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 583 | 583 | return $spotter_array; |
| 584 | 584 | } |
| 585 | 585 | |
@@ -595,13 +595,13 @@ discard block |
||
| 595 | 595 | date_default_timezone_set('UTC'); |
| 596 | 596 | |
| 597 | 597 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 598 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 598 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 599 | 599 | |
| 600 | 600 | try { |
| 601 | 601 | |
| 602 | 602 | $sth = $this->db->prepare($query); |
| 603 | 603 | $sth->execute(array(':ident' => $ident)); |
| 604 | - } catch(PDOException $e) { |
|
| 604 | + } catch (PDOException $e) { |
|
| 605 | 605 | echo $e->getMessage(); |
| 606 | 606 | die; |
| 607 | 607 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | * @return Array the spotter information |
| 617 | 617 | * |
| 618 | 618 | */ |
| 619 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 619 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 620 | 620 | { |
| 621 | 621 | global $globalDBdriver, $globalLiveInterval; |
| 622 | 622 | date_default_timezone_set('UTC'); |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | try { |
| 636 | 636 | $sth = $this->db->prepare($query); |
| 637 | 637 | $sth->execute(array(':id' => $id)); |
| 638 | - } catch(PDOException $e) { |
|
| 638 | + } catch (PDOException $e) { |
|
| 639 | 639 | echo $e->getMessage(); |
| 640 | 640 | die; |
| 641 | 641 | } |
@@ -653,12 +653,12 @@ discard block |
||
| 653 | 653 | { |
| 654 | 654 | date_default_timezone_set('UTC'); |
| 655 | 655 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 656 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 656 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 657 | 657 | try { |
| 658 | 658 | |
| 659 | 659 | $sth = $this->db->prepare($query); |
| 660 | 660 | $sth->execute(array(':ident' => $ident)); |
| 661 | - } catch(PDOException $e) { |
|
| 661 | + } catch (PDOException $e) { |
|
| 662 | 662 | echo $e->getMessage(); |
| 663 | 663 | die; |
| 664 | 664 | } |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | |
| 689 | 689 | $sth = $this->db->prepare($query); |
| 690 | 690 | $sth->execute(); |
| 691 | - } catch(PDOException $e) { |
|
| 691 | + } catch (PDOException $e) { |
|
| 692 | 692 | return "error"; |
| 693 | 693 | } |
| 694 | 694 | |
@@ -711,14 +711,14 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | $sth = $this->db->prepare($query); |
| 713 | 713 | $sth->execute(); |
| 714 | - } catch(PDOException $e) { |
|
| 714 | + } catch (PDOException $e) { |
|
| 715 | 715 | return "error"; |
| 716 | 716 | } |
| 717 | 717 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 718 | 718 | $i = 0; |
| 719 | - $j =0; |
|
| 719 | + $j = 0; |
|
| 720 | 720 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 721 | - foreach($all as $row) |
|
| 721 | + foreach ($all as $row) |
|
| 722 | 722 | { |
| 723 | 723 | $i++; |
| 724 | 724 | $j++; |
@@ -726,9 +726,9 @@ discard block |
||
| 726 | 726 | if ($globalDebug) echo "."; |
| 727 | 727 | try { |
| 728 | 728 | |
| 729 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 729 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 730 | 730 | $sth->execute(); |
| 731 | - } catch(PDOException $e) { |
|
| 731 | + } catch (PDOException $e) { |
|
| 732 | 732 | return "error"; |
| 733 | 733 | } |
| 734 | 734 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -739,9 +739,9 @@ discard block |
||
| 739 | 739 | if ($i > 0) { |
| 740 | 740 | try { |
| 741 | 741 | |
| 742 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 742 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 743 | 743 | $sth->execute(); |
| 744 | - } catch(PDOException $e) { |
|
| 744 | + } catch (PDOException $e) { |
|
| 745 | 745 | return "error"; |
| 746 | 746 | } |
| 747 | 747 | } |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | $sth = $this->db->prepare($query); |
| 756 | 756 | $sth->execute(); |
| 757 | - } catch(PDOException $e) { |
|
| 757 | + } catch (PDOException $e) { |
|
| 758 | 758 | return "error"; |
| 759 | 759 | } |
| 760 | 760 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -802,13 +802,13 @@ discard block |
||
| 802 | 802 | public function deleteLiveSpotterDataByIdent($ident) |
| 803 | 803 | { |
| 804 | 804 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 805 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 805 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 806 | 806 | |
| 807 | 807 | try { |
| 808 | 808 | |
| 809 | 809 | $sth = $this->db->prepare($query); |
| 810 | 810 | $sth->execute(array(':ident' => $ident)); |
| 811 | - } catch(PDOException $e) { |
|
| 811 | + } catch (PDOException $e) { |
|
| 812 | 812 | return "error"; |
| 813 | 813 | } |
| 814 | 814 | |
@@ -824,13 +824,13 @@ discard block |
||
| 824 | 824 | public function deleteLiveSpotterDataById($id) |
| 825 | 825 | { |
| 826 | 826 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 827 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 827 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 828 | 828 | |
| 829 | 829 | try { |
| 830 | 830 | |
| 831 | 831 | $sth = $this->db->prepare($query); |
| 832 | 832 | $sth->execute(array(':id' => $id)); |
| 833 | - } catch(PDOException $e) { |
|
| 833 | + } catch (PDOException $e) { |
|
| 834 | 834 | return "error"; |
| 835 | 835 | } |
| 836 | 836 | |
@@ -848,13 +848,13 @@ discard block |
||
| 848 | 848 | { |
| 849 | 849 | global $globalDBdriver, $globalTimezone; |
| 850 | 850 | if ($globalDBdriver == 'mysql') { |
| 851 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 851 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 852 | 852 | WHERE spotter_live.ident = :ident |
| 853 | 853 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 854 | 854 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 855 | 855 | $query_data = array(':ident' => $ident); |
| 856 | 856 | } else { |
| 857 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 857 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 858 | 858 | WHERE spotter_live.ident = :ident |
| 859 | 859 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 860 | 860 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | $sth = $this->db->prepare($query); |
| 865 | 865 | $sth->execute($query_data); |
| 866 | - $ident_result=''; |
|
| 867 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 866 | + $ident_result = ''; |
|
| 867 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 868 | 868 | { |
| 869 | 869 | $ident_result = $row['ident']; |
| 870 | 870 | } |
@@ -881,13 +881,13 @@ discard block |
||
| 881 | 881 | { |
| 882 | 882 | global $globalDBdriver, $globalTimezone; |
| 883 | 883 | if ($globalDBdriver == 'mysql') { |
| 884 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 884 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 885 | 885 | WHERE spotter_live.ident = :ident |
| 886 | 886 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 887 | 887 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 888 | 888 | $query_data = array(':ident' => $ident); |
| 889 | 889 | } else { |
| 890 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 890 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 891 | 891 | WHERE spotter_live.ident = :ident |
| 892 | 892 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
| 893 | 893 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | $sth = $this->db->prepare($query); |
| 898 | 898 | $sth->execute($query_data); |
| 899 | - $ident_result=''; |
|
| 900 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 899 | + $ident_result = ''; |
|
| 900 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 901 | 901 | { |
| 902 | 902 | $ident_result = $row['flightaware_id']; |
| 903 | 903 | } |
@@ -914,13 +914,13 @@ discard block |
||
| 914 | 914 | { |
| 915 | 915 | global $globalDBdriver, $globalTimezone; |
| 916 | 916 | if ($globalDBdriver == 'mysql') { |
| 917 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 917 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 918 | 918 | WHERE spotter_live.flightaware_id = :id |
| 919 | 919 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 920 | 920 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 921 | 921 | $query_data = array(':id' => $id); |
| 922 | 922 | } else { |
| 923 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 923 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 924 | 924 | WHERE spotter_live.flightaware_id = :id |
| 925 | 925 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 926 | 926 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | $sth = $this->db->prepare($query); |
| 931 | 931 | $sth->execute($query_data); |
| 932 | - $ident_result=''; |
|
| 933 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 932 | + $ident_result = ''; |
|
| 933 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 934 | 934 | { |
| 935 | 935 | $ident_result = $row['flightaware_id']; |
| 936 | 936 | } |
@@ -947,13 +947,13 @@ discard block |
||
| 947 | 947 | { |
| 948 | 948 | global $globalDBdriver, $globalTimezone; |
| 949 | 949 | if ($globalDBdriver == 'mysql') { |
| 950 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 950 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 951 | 951 | WHERE spotter_live.ModeS = :modes |
| 952 | 952 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 953 | 953 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 954 | 954 | $query_data = array(':modes' => $modes); |
| 955 | 955 | } else { |
| 956 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 956 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 957 | 957 | WHERE spotter_live.ModeS = :modes |
| 958 | 958 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
| 959 | 959 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -962,8 +962,8 @@ discard block |
||
| 962 | 962 | |
| 963 | 963 | $sth = $this->db->prepare($query); |
| 964 | 964 | $sth->execute($query_data); |
| 965 | - $ident_result=''; |
|
| 966 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 965 | + $ident_result = ''; |
|
| 966 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 967 | 967 | { |
| 968 | 968 | //$ident_result = $row['spotter_live_id']; |
| 969 | 969 | $ident_result = $row['flightaware_id']; |
@@ -988,8 +988,8 @@ discard block |
||
| 988 | 988 | return array(); |
| 989 | 989 | } else { |
| 990 | 990 | $q_array = explode(" ", $q); |
| 991 | - foreach ($q_array as $q_item){ |
|
| 992 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 991 | + foreach ($q_array as $q_item) { |
|
| 992 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 993 | 993 | $additional_query .= " AND ("; |
| 994 | 994 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
| 995 | 995 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -1004,11 +1004,11 @@ discard block |
||
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | if ($globalDBdriver == 'mysql') { |
| 1007 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1007 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1008 | 1008 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1009 | 1009 | AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1010 | 1010 | } else { |
| 1011 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1011 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1012 | 1012 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1013 | 1013 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1014 | 1014 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | * @return String success or false |
| 1029 | 1029 | * |
| 1030 | 1030 | */ |
| 1031 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 1031 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 1032 | 1032 | { |
| 1033 | 1033 | global $globalURL, $globalArchive, $globalDebug; |
| 1034 | 1034 | $Common = new Common(); |
@@ -1128,27 +1128,27 @@ discard block |
||
| 1128 | 1128 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1129 | 1129 | |
| 1130 | 1130 | |
| 1131 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1132 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1133 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1134 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1135 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1136 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1137 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1138 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1139 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1140 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1141 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1142 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1143 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1144 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1145 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1146 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1147 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1148 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1149 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1150 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1151 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1131 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1132 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1133 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1134 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1135 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1136 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1137 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1138 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1139 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1140 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1141 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1142 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1143 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1144 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1145 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1146 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1147 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1148 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1149 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1150 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1151 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1152 | 1152 | |
| 1153 | 1153 | $airline_name = ''; |
| 1154 | 1154 | $airline_icao = ''; |
@@ -1170,10 +1170,10 @@ discard block |
||
| 1170 | 1170 | $arrival_airport_country = ''; |
| 1171 | 1171 | |
| 1172 | 1172 | |
| 1173 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1174 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1175 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1176 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1173 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1174 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1175 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1176 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1177 | 1177 | |
| 1178 | 1178 | $query = ''; |
| 1179 | 1179 | if ($globalArchive) { |
@@ -1184,19 +1184,19 @@ discard block |
||
| 1184 | 1184 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
| 1185 | 1185 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
| 1186 | 1186 | |
| 1187 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
| 1187 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
| 1188 | 1188 | try { |
| 1189 | 1189 | |
| 1190 | 1190 | $sth = $this->db->prepare($query); |
| 1191 | 1191 | $sth->execute($query_values); |
| 1192 | 1192 | $sth->closeCursor(); |
| 1193 | - } catch(PDOException $e) { |
|
| 1193 | + } catch (PDOException $e) { |
|
| 1194 | 1194 | return "error : ".$e->getMessage(); |
| 1195 | 1195 | } |
| 1196 | 1196 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1197 | 1197 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1198 | 1198 | $SpotterArchive = new SpotterArchive($this->db); |
| 1199 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1199 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1200 | 1200 | if ($globalDebug) echo $result.')'; |
| 1201 | 1201 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1202 | 1202 | echo '(Not adding to archive)'; |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | |
| 1210 | 1210 | public function getOrderBy() |
| 1211 | 1211 | { |
| 1212 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1212 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1213 | 1213 | return $orderby; |
| 1214 | 1214 | } |
| 1215 | 1215 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (SpotterLive)'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -126,8 +130,11 @@ discard block |
||
| 126 | 130 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 127 | 131 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 128 | 132 | } |
| 129 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 130 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 133 | + if ($filter_query_where == '' && $where) { |
|
| 134 | + $filter_query_where = ' WHERE'; |
|
| 135 | + } elseif ($filter_query_where != '' && $and) { |
|
| 136 | + $filter_query_where .= ' AND'; |
|
| 137 | + } |
|
| 131 | 138 | if ($filter_query_where != '') { |
| 132 | 139 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 133 | 140 | } |
@@ -168,9 +175,13 @@ discard block |
||
| 168 | 175 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 169 | 176 | } |
| 170 | 177 | } |
| 171 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 178 | + if ($orderby_query == '') { |
|
| 179 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 180 | + } |
|
| 172 | 181 | |
| 173 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 182 | + if (!isset($globalLiveInterval)) { |
|
| 183 | + $globalLiveInterval = '200'; |
|
| 184 | + } |
|
| 174 | 185 | if ($globalDBdriver == 'mysql') { |
| 175 | 186 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 176 | 187 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -193,7 +204,9 @@ discard block |
||
| 193 | 204 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 194 | 205 | date_default_timezone_set('UTC'); |
| 195 | 206 | $filter_query = $this->getFilter($filter,true,true); |
| 196 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 207 | + if (!isset($globalLiveInterval)) { |
|
| 208 | + $globalLiveInterval = '200'; |
|
| 209 | + } |
|
| 197 | 210 | if ($globalDBdriver == 'mysql') { |
| 198 | 211 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 199 | 212 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -244,8 +257,12 @@ discard block |
||
| 244 | 257 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 245 | 258 | $filter_query = $this->getFilter($filter,true,true); |
| 246 | 259 | |
| 247 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 248 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 260 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 261 | + $globalLiveInterval = '200'; |
|
| 262 | + } |
|
| 263 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 264 | + $globalMap3DAircraftsLimit = '300'; |
|
| 265 | + } |
|
| 249 | 266 | if ($globalDBdriver == 'mysql') { |
| 250 | 267 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 251 | 268 | /* |
@@ -256,25 +273,41 @@ discard block |
||
| 256 | 273 | */ |
| 257 | 274 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
| 258 | 275 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 259 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 260 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 276 | + if ($usecoord) { |
|
| 277 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 278 | + } |
|
| 279 | + if ($id != '') { |
|
| 280 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 281 | + } |
|
| 261 | 282 | $query .= "UNION |
| 262 | 283 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 263 | 284 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 264 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 265 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 285 | + if ($usecoord) { |
|
| 286 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 287 | + } |
|
| 288 | + if ($id != '') { |
|
| 289 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 290 | + } |
|
| 266 | 291 | $query .= ") AS spotter |
| 267 | 292 | WHERE latitude <> '0' AND longitude <> '0' |
| 268 | 293 | ORDER BY flightaware_id, date"; |
| 269 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 294 | + if ($limit) { |
|
| 295 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 296 | + } |
|
| 270 | 297 | } else { |
| 271 | 298 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 272 | 299 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 273 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 274 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 300 | + if ($usecoord) { |
|
| 301 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 302 | + } |
|
| 303 | + if ($id != '') { |
|
| 304 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 305 | + } |
|
| 275 | 306 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 276 | 307 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 277 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 308 | + if ($limit) { |
|
| 309 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 310 | + } |
|
| 278 | 311 | } |
| 279 | 312 | } else { |
| 280 | 313 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -286,28 +319,46 @@ discard block |
||
| 286 | 319 | */ |
| 287 | 320 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
| 288 | 321 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 289 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 290 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 322 | + if ($usecoord) { |
|
| 323 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 324 | + } |
|
| 325 | + if ($id != '') { |
|
| 326 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 327 | + } |
|
| 291 | 328 | $query .= "UNION |
| 292 | 329 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 293 | 330 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 294 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 295 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 331 | + if ($usecoord) { |
|
| 332 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 333 | + } |
|
| 334 | + if ($id != '') { |
|
| 335 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 336 | + } |
|
| 296 | 337 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 297 | 338 | $query .= "ORDER BY flightaware_id, date"; |
| 298 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 339 | + if ($limit) { |
|
| 340 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 341 | + } |
|
| 299 | 342 | } else { |
| 300 | 343 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 301 | 344 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 302 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 303 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 345 | + if ($usecoord) { |
|
| 346 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 347 | + } |
|
| 348 | + if ($id != '') { |
|
| 349 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 350 | + } |
|
| 304 | 351 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 305 | 352 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 306 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 353 | + if ($limit) { |
|
| 354 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 355 | + } |
|
| 307 | 356 | } |
| 308 | 357 | } |
| 309 | 358 | $query_values = array(); |
| 310 | - if ($id != '') $query_values = array(':id' => $id); |
|
| 359 | + if ($id != '') { |
|
| 360 | + $query_values = array(':id' => $id); |
|
| 361 | + } |
|
| 311 | 362 | try { |
| 312 | 363 | $sth = $this->db->prepare($query); |
| 313 | 364 | $sth->execute($query_values); |
@@ -330,7 +381,9 @@ discard block |
||
| 330 | 381 | global $globalDBdriver, $globalLiveInterval; |
| 331 | 382 | $filter_query = $this->getFilter($filter,true,true); |
| 332 | 383 | |
| 333 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 384 | + if (!isset($globalLiveInterval)) { |
|
| 385 | + $globalLiveInterval = '200'; |
|
| 386 | + } |
|
| 334 | 387 | if ($globalDBdriver == 'mysql') { |
| 335 | 388 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 336 | 389 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -360,7 +413,9 @@ discard block |
||
| 360 | 413 | { |
| 361 | 414 | global $globalDBdriver, $globalLiveInterval; |
| 362 | 415 | $Spotter = new Spotter($this->db); |
| 363 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 416 | + if (!isset($globalLiveInterval)) { |
|
| 417 | + $globalLiveInterval = '200'; |
|
| 418 | + } |
|
| 364 | 419 | $filter_query = $this->getFilter($filter); |
| 365 | 420 | |
| 366 | 421 | if (is_array($coord)) { |
@@ -368,7 +423,9 @@ discard block |
||
| 368 | 423 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 369 | 424 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 370 | 425 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 371 | - } else return array(); |
|
| 426 | + } else { |
|
| 427 | + return array(); |
|
| 428 | + } |
|
| 372 | 429 | if ($globalDBdriver == 'mysql') { |
| 373 | 430 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 374 | 431 | } else { |
@@ -389,7 +446,9 @@ discard block |
||
| 389 | 446 | { |
| 390 | 447 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 391 | 448 | $Spotter = new Spotter($this->db); |
| 392 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 449 | + if (!isset($globalLiveInterval)) { |
|
| 450 | + $globalLiveInterval = '200'; |
|
| 451 | + } |
|
| 393 | 452 | $filter_query = $this->getFilter($filter,true,true); |
| 394 | 453 | |
| 395 | 454 | if (is_array($coord)) { |
@@ -397,7 +456,9 @@ discard block |
||
| 397 | 456 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 398 | 457 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 399 | 458 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 400 | - } else return array(); |
|
| 459 | + } else { |
|
| 460 | + return array(); |
|
| 461 | + } |
|
| 401 | 462 | if ($globalDBdriver == 'mysql') { |
| 402 | 463 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 403 | 464 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -624,11 +685,15 @@ discard block |
||
| 624 | 685 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 625 | 686 | if ($globalDBdriver == 'mysql') { |
| 626 | 687 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 627 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 688 | + if ($liveinterval) { |
|
| 689 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 690 | + } |
|
| 628 | 691 | $query .= ' ORDER BY date'; |
| 629 | 692 | } else { |
| 630 | 693 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 631 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 694 | + if ($liveinterval) { |
|
| 695 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 696 | + } |
|
| 632 | 697 | $query .= ' ORDER BY date'; |
| 633 | 698 | } |
| 634 | 699 | |
@@ -723,7 +788,9 @@ discard block |
||
| 723 | 788 | $i++; |
| 724 | 789 | $j++; |
| 725 | 790 | if ($j == 30) { |
| 726 | - if ($globalDebug) echo "."; |
|
| 791 | + if ($globalDebug) { |
|
| 792 | + echo "."; |
|
| 793 | + } |
|
| 727 | 794 | try { |
| 728 | 795 | |
| 729 | 796 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1076,7 +1143,9 @@ discard block |
||
| 1076 | 1143 | { |
| 1077 | 1144 | return false; |
| 1078 | 1145 | } |
| 1079 | - } else return ''; |
|
| 1146 | + } else { |
|
| 1147 | + return ''; |
|
| 1148 | + } |
|
| 1080 | 1149 | |
| 1081 | 1150 | if ($longitude != '') |
| 1082 | 1151 | { |
@@ -1084,7 +1153,9 @@ discard block |
||
| 1084 | 1153 | { |
| 1085 | 1154 | return false; |
| 1086 | 1155 | } |
| 1087 | - } else return ''; |
|
| 1156 | + } else { |
|
| 1157 | + return ''; |
|
| 1158 | + } |
|
| 1088 | 1159 | |
| 1089 | 1160 | if ($waypoints != '') |
| 1090 | 1161 | { |
@@ -1100,14 +1171,18 @@ discard block |
||
| 1100 | 1171 | { |
| 1101 | 1172 | return false; |
| 1102 | 1173 | } |
| 1103 | - } else $altitude = 0; |
|
| 1174 | + } else { |
|
| 1175 | + $altitude = 0; |
|
| 1176 | + } |
|
| 1104 | 1177 | if ($altitude_real != '') |
| 1105 | 1178 | { |
| 1106 | 1179 | if (!is_numeric($altitude_real)) |
| 1107 | 1180 | { |
| 1108 | 1181 | return false; |
| 1109 | 1182 | } |
| 1110 | - } else $altitude_real = 0; |
|
| 1183 | + } else { |
|
| 1184 | + $altitude_real = 0; |
|
| 1185 | + } |
|
| 1111 | 1186 | |
| 1112 | 1187 | if ($heading != '') |
| 1113 | 1188 | { |
@@ -1115,7 +1190,9 @@ discard block |
||
| 1115 | 1190 | { |
| 1116 | 1191 | return false; |
| 1117 | 1192 | } |
| 1118 | - } else $heading = 0; |
|
| 1193 | + } else { |
|
| 1194 | + $heading = 0; |
|
| 1195 | + } |
|
| 1119 | 1196 | |
| 1120 | 1197 | if ($groundspeed != '') |
| 1121 | 1198 | { |
@@ -1123,9 +1200,13 @@ discard block |
||
| 1123 | 1200 | { |
| 1124 | 1201 | return false; |
| 1125 | 1202 | } |
| 1126 | - } else $groundspeed = 0; |
|
| 1203 | + } else { |
|
| 1204 | + $groundspeed = 0; |
|
| 1205 | + } |
|
| 1127 | 1206 | date_default_timezone_set('UTC'); |
| 1128 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1207 | + if ($date == '') { |
|
| 1208 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1209 | + } |
|
| 1129 | 1210 | |
| 1130 | 1211 | |
| 1131 | 1212 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1170,14 +1251,24 @@ discard block |
||
| 1170 | 1251 | $arrival_airport_country = ''; |
| 1171 | 1252 | |
| 1172 | 1253 | |
| 1173 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1174 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1175 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1176 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1254 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1255 | + $squawk = NULL; |
|
| 1256 | + } |
|
| 1257 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1258 | + $verticalrate = NULL; |
|
| 1259 | + } |
|
| 1260 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1261 | + $groundspeed = 0; |
|
| 1262 | + } |
|
| 1263 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1264 | + $heading = 0; |
|
| 1265 | + } |
|
| 1177 | 1266 | |
| 1178 | 1267 | $query = ''; |
| 1179 | 1268 | if ($globalArchive) { |
| 1180 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1269 | + if ($globalDebug) { |
|
| 1270 | + echo '-- Delete previous data -- '; |
|
| 1271 | + } |
|
| 1181 | 1272 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1182 | 1273 | } |
| 1183 | 1274 | |
@@ -1194,10 +1285,14 @@ discard block |
||
| 1194 | 1285 | return "error : ".$e->getMessage(); |
| 1195 | 1286 | } |
| 1196 | 1287 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1197 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1288 | + if ($globalDebug) { |
|
| 1289 | + echo '(Add to SBS archive : '; |
|
| 1290 | + } |
|
| 1198 | 1291 | $SpotterArchive = new SpotterArchive($this->db); |
| 1199 | 1292 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1200 | - if ($globalDebug) echo $result.')'; |
|
| 1293 | + if ($globalDebug) { |
|
| 1294 | + echo $result.')'; |
|
| 1295 | + } |
|
| 1201 | 1296 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1202 | 1297 | echo '(Not adding to archive)'; |
| 1203 | 1298 | } elseif ($globalDebug && $noarchive === true) { |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | $min = true; |
| 65 | 65 | $allhistory = false; |
| 66 | 66 | $filter['source'] = array(); |
| 67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
| 74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 68 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 69 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 71 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 72 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 73 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
| 74 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 75 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 76 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 77 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 78 | 78 | |
| 79 | 79 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 80 | 80 | $min = true; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $spotter_array = array(); |
| 84 | 84 | |
| 85 | 85 | if (isset($_GET['ident'])) { |
| 86 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
| 86 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
| 87 | 87 | if ($tracker) { |
| 88 | 88 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
| 89 | 89 | } elseif ($marine) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | $allhistory = true; |
| 99 | 99 | } elseif (isset($_GET['flightaware_id'])) { |
| 100 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 100 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
| 101 | 101 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
| 102 | 102 | if (empty($spotter_array)) { |
| 103 | 103 | $from_archive = true; |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | $allhistory = true; |
| 107 | 107 | } elseif (isset($_GET['famtrack_id'])) { |
| 108 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
| 108 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
| 109 | 109 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
| 110 | 110 | $allhistory = true; |
| 111 | 111 | } elseif (isset($_GET['fammarine_id'])) { |
| 112 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
| 112 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
| 113 | 113 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
| 114 | 114 | $allhistory = true; |
| 115 | 115 | /* |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) { |
| 131 | 131 | $usecoord = true; |
| 132 | - $coord = explode(',',$_GET['coord']); |
|
| 133 | - if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
| 132 | + $coord = explode(',', $_GET['coord']); |
|
| 133 | + if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
| 134 | 134 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
| 135 | 135 | if ($tracker) { |
| 136 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
| 136 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
| 137 | 137 | } elseif ($marine) { |
| 138 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
| 138 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
| 139 | 139 | } else { |
| 140 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
| 140 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
| 141 | 141 | } |
| 142 | 142 | } else { |
| 143 | 143 | if ($tracker) { |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | $from_archive = true; |
| 153 | 153 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 154 | 154 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 155 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 156 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 157 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 158 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 159 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 160 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 155 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 156 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 157 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 158 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 159 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 160 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 161 | 161 | } elseif ($min) { |
| 162 | 162 | if ($tracker) { |
| 163 | 163 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -169,17 +169,17 @@ discard block |
||
| 169 | 169 | # $min = true; |
| 170 | 170 | } else { |
| 171 | 171 | if ($tracker) { |
| 172 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
| 172 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
| 173 | 173 | } elseif ($marine) { |
| 174 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
| 174 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
| 175 | 175 | } else { |
| 176 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
| 176 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($usecoord) { |
| 181 | 181 | if (isset($_GET['archive'])) { |
| 182 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 182 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 183 | 183 | } else { |
| 184 | 184 | if ($tracker) { |
| 185 | 185 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | if ($flightcnt == '') $flightcnt = 0; |
| 193 | 193 | } else $flightcnt = 0; |
| 194 | 194 | |
| 195 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 195 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 196 | 196 | |
| 197 | -$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 197 | +$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 198 | 198 | if ($currenttime != '') $currenttime = round($currenttime/1000); |
| 199 | 199 | |
| 200 | 200 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 214 | 214 | { |
| 215 | 215 | $output .= '"features": ['; |
| 216 | - foreach($spotter_array as $spotter_item) |
|
| 216 | + foreach ($spotter_array as $spotter_item) |
|
| 217 | 217 | { |
| 218 | 218 | $j++; |
| 219 | 219 | unset($idistance); |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 272 | 272 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 273 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 274 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 273 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
| 274 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
| 275 | 275 | //" |
| 276 | 276 | } else { |
| 277 | 277 | if ($compress) $output .= '"c": "NA",'; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 285 | 285 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 286 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
| 286 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
| 287 | 287 | } elseif (isset($spotter_item['aircraft_type'])) { |
| 288 | 288 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
| 289 | 289 | } elseif (!$min) { |
@@ -430,15 +430,15 @@ discard block |
||
| 430 | 430 | if (isset($archivespeed) || $usenextlatlon) { |
| 431 | 431 | if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
| 432 | 432 | if (isset($spotter_item['arrival_airport_latitude'])) { |
| 433 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
| 434 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
| 433 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
| 434 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
| 435 | 435 | $farr_lat = $spotter_item['arrival_airport_latitude']; |
| 436 | 436 | $farr_lon = $spotter_item['arrival_airport_longitude']; |
| 437 | 437 | } else { |
| 438 | 438 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
| 439 | 439 | if (isset($aairport[0]['latitude'])) { |
| 440 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
| 441 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
| 440 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
| 441 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
| 442 | 442 | $farr_lat = $aairport[0]['latitude']; |
| 443 | 443 | $farr_lon = $aairport[0]['longitude']; |
| 444 | 444 | } |
@@ -451,59 +451,59 @@ discard block |
||
| 451 | 451 | if ($currenttime != '') { |
| 452 | 452 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 453 | 453 | if (isset($archivespeed)) { |
| 454 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 455 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 454 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 455 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 456 | 456 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 457 | 457 | else { |
| 458 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 459 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 458 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 459 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 460 | 460 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 461 | 461 | else { |
| 462 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 462 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 463 | 463 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | } elseif ($usenextlatlon) { |
| 467 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 468 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 467 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 468 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 469 | 469 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 470 | 470 | else { |
| 471 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 472 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 471 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 472 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 473 | 473 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 474 | 474 | else { |
| 475 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 475 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 476 | 476 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | } else { |
| 481 | 481 | if (isset($archivespeed)) { |
| 482 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 482 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 483 | 483 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 484 | 484 | } elseif ($usenextlatlon) { |
| 485 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 485 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 486 | 486 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | } else { |
| 490 | 490 | if (isset($archivespeed)) { |
| 491 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 492 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 491 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 492 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 493 | 493 | if (!isset($idistance) || $fdistance < $idistance) { |
| 494 | 494 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 495 | 495 | } else { |
| 496 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed); |
|
| 496 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed); |
|
| 497 | 497 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 498 | 498 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 499 | 499 | } |
| 500 | 500 | } elseif ($usenextlatlon) { |
| 501 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 502 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 501 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 502 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 503 | 503 | if (!isset($idistance) || $fdistance < $idistance) { |
| 504 | 504 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 505 | 505 | } else { |
| 506 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading); |
|
| 506 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading); |
|
| 507 | 507 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 508 | 508 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 509 | 509 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | if (!$min) $output .= '"image": "'.$image.'",'; |
| 514 | 514 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 515 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
| 515 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
| 516 | 516 | } |
| 517 | 517 | if (isset($spotter_item['image_source_website'])) { |
| 518 | 518 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
| 535 | 535 | } |
| 536 | 536 | if (isset($spotter_item['acars'])) { |
| 537 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
| 537 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
| 538 | 538 | } |
| 539 | 539 | // type when not aircraft ? |
| 540 | 540 | if (isset($spotter_item['type'])) { |
@@ -554,12 +554,12 @@ discard block |
||
| 554 | 554 | if ($currenttime != '') { |
| 555 | 555 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 556 | 556 | if (!isset($archivespeed)) $archivespeed = 1; |
| 557 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
| 558 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 557 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
| 558 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 559 | 559 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
| 560 | 560 | else { |
| 561 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
| 562 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 561 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
| 562 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 563 | 563 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
| 564 | 564 | else { |
| 565 | 565 | $output .= $spotter_item['longitude'].', '; |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | |
| 639 | 639 | } |
| 640 | 640 | */ |
| 641 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
| 641 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
| 642 | 642 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 643 | 643 | |
| 644 | 644 | if ( |
@@ -646,11 +646,11 @@ discard block |
||
| 646 | 646 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
| 647 | 647 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 648 | 648 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 649 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 649 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 650 | 650 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
| 651 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
| 651 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
| 652 | 652 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
| 653 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
| 653 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
| 654 | 654 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
| 655 | 655 | ) { |
| 656 | 656 | if ($tracker) { |
@@ -679,9 +679,9 @@ discard block |
||
| 679 | 679 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
| 680 | 680 | $MapMatching = new MapMatching(); |
| 681 | 681 | if (isset($spotter_item['date_iso_8601'])) { |
| 682 | - $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601']))))); |
|
| 682 | + $spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601']))))); |
|
| 683 | 683 | } else { |
| 684 | - $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date']))))); |
|
| 684 | + $spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date']))))); |
|
| 685 | 685 | } |
| 686 | 686 | $spotter_history_array = $MapMatching->match($spotter_history_array_mm); |
| 687 | 687 | } |
@@ -713,9 +713,9 @@ discard block |
||
| 713 | 713 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
| 714 | 714 | } |
| 715 | 715 | $output_history .= '['; |
| 716 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 717 | - $output_history .= $spotter_history['latitude'].', '; |
|
| 718 | - $output_history .= $spotter_history['altitude']*30.48; |
|
| 716 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 717 | + $output_history .= $spotter_history['latitude'].', '; |
|
| 718 | + $output_history .= $spotter_history['altitude']*30.48; |
|
| 719 | 719 | $output_history .= '],'; |
| 720 | 720 | /* |
| 721 | 721 | if ($from_archive === false) { |
@@ -738,8 +738,8 @@ discard block |
||
| 738 | 738 | $d = true; |
| 739 | 739 | } |
| 740 | 740 | $output_history .= '['; |
| 741 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 742 | - $output_history .= $spotter_history['latitude']; |
|
| 741 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 742 | + $output_history .= $spotter_history['latitude']; |
|
| 743 | 743 | $output_history .= '],'; |
| 744 | 744 | /* |
| 745 | 745 | if ($from_archive === false) { |
@@ -755,9 +755,9 @@ discard block |
||
| 755 | 755 | //echo $output_history; |
| 756 | 756 | if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) { |
| 757 | 757 | $output_historyd = '['; |
| 758 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
| 759 | - $output_historyd .= $spotter_item['latitude']; |
|
| 760 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 758 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
| 759 | + $output_historyd .= $spotter_item['latitude']; |
|
| 760 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 761 | 761 | $output_historyd .= '],'; |
| 762 | 762 | //$output_history = $output_historyd.$output_history; |
| 763 | 763 | $output_history = $output_history.$output_historyd; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $last = array_pop($spotter_history_array); |
| 766 | 766 | $latitude = $last['latitude']; |
| 767 | 767 | $longitude = $last['longitude']; |
| 768 | - $output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output); |
|
| 768 | + $output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | $output_history = substr($output_history, 0, -1); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 779 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 780 | 780 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 781 | 781 | && (isset($spotter_item['departure_airport']) |
| 782 | 782 | && $spotter_item['departure_airport'] != 'NA' |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | |
| 811 | 811 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 812 | 812 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 813 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 813 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 814 | 814 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 815 | 815 | && (isset($spotter_item['arrival_airport']) |
| 816 | 816 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -837,11 +837,11 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | if ($havedata) { |
| 840 | - $line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon); |
|
| 840 | + $line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon); |
|
| 841 | 841 | foreach ($line[0] as $coord) { |
| 842 | 842 | $output_dest .= '['.$coord[0].','.$coord[1].'],'; |
| 843 | 843 | } |
| 844 | - $output_dest = substr($output_dest, 0, -1); |
|
| 844 | + $output_dest = substr($output_dest, 0, -1); |
|
| 845 | 845 | } |
| 846 | 846 | $output_dest .= ']}},'; |
| 847 | 847 | if ($havedata) $output .= $output_dest; |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $output = substr($output, 0, -1); |
| 852 | 852 | $output .= ']'; |
| 853 | 853 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 854 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
| 854 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
| 855 | 855 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
| 856 | 856 | $output .= '"fc": "'.$j.'"'; |
| 857 | 857 | } else { |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | $tracker = false; |
| 13 | 13 | $marine = false; |
| 14 | 14 | $usecoord = false; |
| 15 | -if (isset($_GET['test'])) exit(); |
|
| 15 | +if (isset($_GET['test'])) { |
|
| 16 | + exit(); |
|
| 17 | +} |
|
| 16 | 18 | if (isset($_GET['tracker'])) { |
| 17 | 19 | $tracker = true; |
| 18 | 20 | } |
@@ -57,28 +59,55 @@ discard block |
||
| 57 | 59 | } |
| 58 | 60 | header('Content-Type: text/javascript'); |
| 59 | 61 | |
| 60 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 61 | -else $compress = $globalJsonCompress; |
|
| 62 | +if (!isset($globalJsonCompress)) { |
|
| 63 | + $compress = true; |
|
| 64 | +} else { |
|
| 65 | + $compress = $globalJsonCompress; |
|
| 66 | +} |
|
| 62 | 67 | |
| 63 | 68 | $from_archive = false; |
| 64 | 69 | $min = true; |
| 65 | 70 | $allhistory = false; |
| 66 | 71 | $filter['source'] = array(); |
| 67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
| 74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 73 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 74 | +} |
|
| 75 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 76 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 77 | +} |
|
| 78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 79 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 80 | +} |
|
| 81 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 82 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 83 | +} |
|
| 84 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 85 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 86 | +} |
|
| 87 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 88 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 89 | +} |
|
| 90 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') { |
|
| 91 | + $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
| 92 | +} |
|
| 93 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 94 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 95 | +} |
|
| 96 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 97 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 98 | +} |
|
| 99 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 100 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 101 | +} |
|
| 102 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
| 103 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 104 | +} |
|
| 78 | 105 | |
| 79 | 106 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 80 | 107 | $min = true; |
| 81 | -} else $min = false; |
|
| 108 | +} else { |
|
| 109 | + $min = false; |
|
| 110 | +} |
|
| 82 | 111 | |
| 83 | 112 | $spotter_array = array(); |
| 84 | 113 | |
@@ -189,24 +218,38 @@ discard block |
||
| 189 | 218 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 190 | 219 | } |
| 191 | 220 | } |
| 192 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 193 | -} else $flightcnt = 0; |
|
| 221 | + if ($flightcnt == '') { |
|
| 222 | + $flightcnt = 0; |
|
| 223 | + } |
|
| 224 | + } else { |
|
| 225 | + $flightcnt = 0; |
|
| 226 | +} |
|
| 194 | 227 | |
| 195 | 228 | $sqltime = round(microtime(true)-$begintime,2); |
| 196 | 229 | |
| 197 | 230 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
| 198 | -if ($currenttime != '') $currenttime = round($currenttime/1000); |
|
| 231 | +if ($currenttime != '') { |
|
| 232 | + $currenttime = round($currenttime/1000); |
|
| 233 | +} |
|
| 199 | 234 | |
| 200 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
| 201 | -else $usenextlatlon = true; |
|
| 202 | -if ($usenextlatlon === false) $currenttime = ''; |
|
| 235 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
| 236 | + $usenextlatlon = false; |
|
| 237 | +} else { |
|
| 238 | + $usenextlatlon = true; |
|
| 239 | +} |
|
| 240 | +if ($usenextlatlon === false) { |
|
| 241 | + $currenttime = ''; |
|
| 242 | +} |
|
| 203 | 243 | $j = 0; |
| 204 | 244 | $prev_flightaware_id = ''; |
| 205 | 245 | $aircrafts_shadow = array(); |
| 206 | 246 | $output = '{'; |
| 207 | 247 | $output .= '"type": "FeatureCollection",'; |
| 208 | - if ($min) $output .= '"minimal": "true",'; |
|
| 209 | - else $output .= '"minimal": "false",'; |
|
| 248 | + if ($min) { |
|
| 249 | + $output .= '"minimal": "true",'; |
|
| 250 | + } else { |
|
| 251 | + $output .= '"minimal": "false",'; |
|
| 252 | + } |
|
| 210 | 253 | //$output .= '"fc": "'.$flightcnt.'",'; |
| 211 | 254 | $output .= '"sqt": "'.$sqltime.'",'; |
| 212 | 255 | |
@@ -251,18 +294,29 @@ discard block |
||
| 251 | 294 | } |
| 252 | 295 | $output .= '"properties": {'; |
| 253 | 296 | if (isset($spotter_item['flightaware_id'])) { |
| 254 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 255 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 297 | + if ($compress) { |
|
| 298 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 299 | + } else { |
|
| 300 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 301 | + } |
|
| 256 | 302 | } elseif (isset($spotter_item['famtrackid'])) { |
| 257 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 258 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 303 | + if ($compress) { |
|
| 304 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
| 305 | + } else { |
|
| 306 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
| 307 | + } |
|
| 259 | 308 | } elseif (isset($spotter_item['fammarine_id'])) { |
| 260 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 261 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 309 | + if ($compress) { |
|
| 310 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
| 311 | + } else { |
|
| 312 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
| 313 | + } |
|
| 262 | 314 | } |
| 263 | 315 | $output .= '"fc": "'.$flightcnt.'",'; |
| 264 | 316 | $output .= '"sqt": "'.$sqltime.'",'; |
| 265 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 317 | + if (isset($begindate)) { |
|
| 318 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 319 | + } |
|
| 266 | 320 | |
| 267 | 321 | /* |
| 268 | 322 | if ($min) $output .= '"minimal": "true",'; |
@@ -270,16 +324,25 @@ discard block |
||
| 270 | 324 | */ |
| 271 | 325 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 272 | 326 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 273 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 274 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 327 | + if ($compress) { |
|
| 328 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 329 | + } else { |
|
| 330 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
| 331 | + } |
|
| 275 | 332 | //" |
| 276 | 333 | } else { |
| 277 | - if ($compress) $output .= '"c": "NA",'; |
|
| 278 | - else $output .= '"callsign": "NA",'; |
|
| 334 | + if ($compress) { |
|
| 335 | + $output .= '"c": "NA",'; |
|
| 336 | + } else { |
|
| 337 | + $output .= '"callsign": "NA",'; |
|
| 338 | + } |
|
| 279 | 339 | } |
| 280 | 340 | if (isset($spotter_item['registration'])) { |
| 281 | - if ($compress) $output .= '"reg": "'.$spotter_item['registration'].'",'; |
|
| 282 | - else $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 341 | + if ($compress) { |
|
| 342 | + $output .= '"reg": "'.$spotter_item['registration'].'",'; |
|
| 343 | + } else { |
|
| 344 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 345 | + } |
|
| 283 | 346 | } |
| 284 | 347 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 285 | 348 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
@@ -290,20 +353,30 @@ discard block |
||
| 290 | 353 | $output .= '"aircraft_name": "NA",'; |
| 291 | 354 | } |
| 292 | 355 | if (isset($spotter_item['aircraft_icao'])) { |
| 293 | - if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 294 | - else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 356 | + if ($compress) { |
|
| 357 | + $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 358 | + } else { |
|
| 359 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 360 | + } |
|
| 295 | 361 | } |
| 296 | 362 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) { |
| 297 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 298 | - else { |
|
| 363 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 364 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 365 | + } else { |
|
| 299 | 366 | $aircraft_icao = $spotter_item['aircraft_icao']; |
| 300 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 301 | - else { |
|
| 367 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
| 368 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 369 | + } else { |
|
| 302 | 370 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 303 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 304 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 305 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
| 306 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 371 | + if (count($aircraft_info) > 0) { |
|
| 372 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 373 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 374 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 375 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
| 376 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
| 377 | + } else { |
|
| 378 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 379 | + } |
|
| 307 | 380 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
| 308 | 381 | } |
| 309 | 382 | } |
@@ -311,73 +384,139 @@ discard block |
||
| 311 | 384 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
| 312 | 385 | if ($tracker) { |
| 313 | 386 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
| 314 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
| 315 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 387 | + if ($compress) { |
|
| 388 | + $output .= '"as": "ambulance.png",'; |
|
| 389 | + } else { |
|
| 390 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 391 | + } |
|
| 316 | 392 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
| 317 | - if ($compress) $output .= '"as": "police.png",'; |
|
| 318 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
| 393 | + if ($compress) { |
|
| 394 | + $output .= '"as": "police.png",'; |
|
| 395 | + } else { |
|
| 396 | + $output .= '"aircraft_shadow": "police.png",'; |
|
| 397 | + } |
|
| 319 | 398 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
| 320 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 321 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 399 | + if ($compress) { |
|
| 400 | + $output .= '"as": "ship.png",'; |
|
| 401 | + } else { |
|
| 402 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 403 | + } |
|
| 322 | 404 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
| 323 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 324 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 405 | + if ($compress) { |
|
| 406 | + $output .= '"as": "ship.png",'; |
|
| 407 | + } else { |
|
| 408 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 409 | + } |
|
| 325 | 410 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
| 326 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 327 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 411 | + if ($compress) { |
|
| 412 | + $output .= '"as": "ship.png",'; |
|
| 413 | + } else { |
|
| 414 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 415 | + } |
|
| 328 | 416 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
| 329 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 330 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 417 | + if ($compress) { |
|
| 418 | + $output .= '"as": "truck.png",'; |
|
| 419 | + } else { |
|
| 420 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 421 | + } |
|
| 331 | 422 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
| 332 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 333 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 423 | + if ($compress) { |
|
| 424 | + $output .= '"as": "truck.png",'; |
|
| 425 | + } else { |
|
| 426 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 427 | + } |
|
| 334 | 428 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
| 335 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 336 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 429 | + if ($compress) { |
|
| 430 | + $output .= '"as": "aircraft.png",'; |
|
| 431 | + } else { |
|
| 432 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 433 | + } |
|
| 337 | 434 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
| 338 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 339 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 435 | + if ($compress) { |
|
| 436 | + $output .= '"as": "aircraft.png",'; |
|
| 437 | + } else { |
|
| 438 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 439 | + } |
|
| 340 | 440 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
| 341 | - if ($compress) $output .= '"as": "helico.png",'; |
|
| 342 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
| 441 | + if ($compress) { |
|
| 442 | + $output .= '"as": "helico.png",'; |
|
| 443 | + } else { |
|
| 444 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
| 445 | + } |
|
| 343 | 446 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
| 344 | - if ($compress) $output .= '"as": "rail.png",'; |
|
| 345 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
| 447 | + if ($compress) { |
|
| 448 | + $output .= '"as": "rail.png",'; |
|
| 449 | + } else { |
|
| 450 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
| 451 | + } |
|
| 346 | 452 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
| 347 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
| 348 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 453 | + if ($compress) { |
|
| 454 | + $output .= '"as": "firetruck.png",'; |
|
| 455 | + } else { |
|
| 456 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 457 | + } |
|
| 349 | 458 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
| 350 | - if ($compress) $output .= '"as": "bus.png",'; |
|
| 351 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
| 459 | + if ($compress) { |
|
| 460 | + $output .= '"as": "bus.png",'; |
|
| 461 | + } else { |
|
| 462 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
| 463 | + } |
|
| 352 | 464 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
| 353 | - if ($compress) $output .= '"as": "phone.png",'; |
|
| 354 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
| 465 | + if ($compress) { |
|
| 466 | + $output .= '"as": "phone.png",'; |
|
| 467 | + } else { |
|
| 468 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
| 469 | + } |
|
| 355 | 470 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
| 356 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
| 357 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 471 | + if ($compress) { |
|
| 472 | + $output .= '"as": "jogger.png",'; |
|
| 473 | + } else { |
|
| 474 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 475 | + } |
|
| 358 | 476 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
| 359 | - if ($compress) $output .= '"as": "bike.png",'; |
|
| 360 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
| 477 | + if ($compress) { |
|
| 478 | + $output .= '"as": "bike.png",'; |
|
| 479 | + } else { |
|
| 480 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
| 481 | + } |
|
| 361 | 482 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
| 362 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
| 363 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 483 | + if ($compress) { |
|
| 484 | + $output .= '"as": "motorcycle.png",'; |
|
| 485 | + } else { |
|
| 486 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 487 | + } |
|
| 364 | 488 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
| 365 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
| 366 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 489 | + if ($compress) { |
|
| 490 | + $output .= '"as": "balloon.png",'; |
|
| 491 | + } else { |
|
| 492 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 493 | + } |
|
| 367 | 494 | } else { |
| 368 | - if ($compress) $output .= '"as": "car.png",'; |
|
| 369 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
| 495 | + if ($compress) { |
|
| 496 | + $output .= '"as": "car.png",'; |
|
| 497 | + } else { |
|
| 498 | + $output .= '"aircraft_shadow": "car.png",'; |
|
| 499 | + } |
|
| 370 | 500 | } |
| 371 | 501 | } elseif ($marine) { |
| 372 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 373 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 502 | + if ($compress) { |
|
| 503 | + $output .= '"as": "ship.png",'; |
|
| 504 | + } else { |
|
| 505 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 506 | + } |
|
| 374 | 507 | } else { |
| 375 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 376 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 508 | + if ($compress) { |
|
| 509 | + $output .= '"as": "default.png",'; |
|
| 510 | + } else { |
|
| 511 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 512 | + } |
|
| 377 | 513 | } |
| 378 | 514 | } else { |
| 379 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 380 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 515 | + if ($compress) { |
|
| 516 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 517 | + } else { |
|
| 518 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 519 | + } |
|
| 381 | 520 | } |
| 382 | 521 | if (isset($spotter_item['airline_name'])) { |
| 383 | 522 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -385,8 +524,11 @@ discard block |
||
| 385 | 524 | $output .= '"airline_name": "NA",'; |
| 386 | 525 | } |
| 387 | 526 | if (isset($spotter_item['departure_airport'])) { |
| 388 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 389 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 527 | + if ($compress) { |
|
| 528 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 529 | + } else { |
|
| 530 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 531 | + } |
|
| 390 | 532 | } |
| 391 | 533 | if (isset($spotter_item['departure_airport_city'])) { |
| 392 | 534 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -398,8 +540,11 @@ discard block |
||
| 398 | 540 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 399 | 541 | } |
| 400 | 542 | if (isset($spotter_item['arrival_airport'])) { |
| 401 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 402 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 543 | + if ($compress) { |
|
| 544 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 545 | + } else { |
|
| 546 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 547 | + } |
|
| 403 | 548 | } |
| 404 | 549 | if (isset($spotter_item['arrival_airport_city'])) { |
| 405 | 550 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -418,11 +563,17 @@ discard block |
||
| 418 | 563 | } |
| 419 | 564 | |
| 420 | 565 | if (isset($spotter_item['real_altitude'])) { |
| 421 | - if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
| 422 | - else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
| 566 | + if ($compress) { |
|
| 567 | + $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
| 568 | + } else { |
|
| 569 | + $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
| 570 | + } |
|
| 423 | 571 | } elseif (isset($spotter_item['altitude'])) { |
| 424 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 425 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 572 | + if ($compress) { |
|
| 573 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 574 | + } else { |
|
| 575 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 576 | + } |
|
| 426 | 577 | } |
| 427 | 578 | |
| 428 | 579 | $heading = $spotter_item['heading']; |
@@ -446,19 +597,24 @@ discard block |
||
| 446 | 597 | } |
| 447 | 598 | } |
| 448 | 599 | |
| 449 | - if ($compress)$output .= '"h": "'.$heading.'",'; |
|
| 450 | - else $output .= '"heading": "'.$heading.'",'; |
|
| 600 | + if ($compress) { |
|
| 601 | + $output .= '"h": "'.$heading.'",'; |
|
| 602 | + } else { |
|
| 603 | + $output .= '"heading": "'.$heading.'",'; |
|
| 604 | + } |
|
| 451 | 605 | if ($currenttime != '') { |
| 452 | 606 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 453 | 607 | if (isset($archivespeed)) { |
| 454 | 608 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
| 455 | 609 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 456 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 457 | - else { |
|
| 610 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 611 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 612 | + } else { |
|
| 458 | 613 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
| 459 | 614 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 460 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 461 | - else { |
|
| 615 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 616 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 617 | + } else { |
|
| 462 | 618 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
| 463 | 619 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 464 | 620 | } |
@@ -466,12 +622,14 @@ discard block |
||
| 466 | 622 | } elseif ($usenextlatlon) { |
| 467 | 623 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
| 468 | 624 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 469 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 470 | - else { |
|
| 625 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 626 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 627 | + } else { |
|
| 471 | 628 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
| 472 | 629 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 473 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 474 | - else { |
|
| 630 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 631 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
| 632 | + } else { |
|
| 475 | 633 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
| 476 | 634 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 477 | 635 | } |
@@ -510,7 +668,9 @@ discard block |
||
| 510 | 668 | } |
| 511 | 669 | } |
| 512 | 670 | |
| 513 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 671 | + if (!$min) { |
|
| 672 | + $output .= '"image": "'.$image.'",'; |
|
| 673 | + } |
|
| 514 | 674 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 515 | 675 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 516 | 676 | } |
@@ -518,8 +678,11 @@ discard block |
||
| 518 | 678 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 519 | 679 | } |
| 520 | 680 | if (isset($spotter_item['squawk'])) { |
| 521 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 522 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 681 | + if ($compress) { |
|
| 682 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 683 | + } else { |
|
| 684 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 685 | + } |
|
| 523 | 686 | } |
| 524 | 687 | if (isset($spotter_item['squawk_usage'])) { |
| 525 | 688 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -538,14 +701,23 @@ discard block |
||
| 538 | 701 | } |
| 539 | 702 | // type when not aircraft ? |
| 540 | 703 | if (isset($spotter_item['type'])) { |
| 541 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 542 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 704 | + if ($compress) { |
|
| 705 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 706 | + } else { |
|
| 707 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 708 | + } |
|
| 543 | 709 | } elseif ($marine) { |
| 544 | - if ($compress) $output .= '"t": "ship"'; |
|
| 545 | - else $output .= '"type": "ship"'; |
|
| 710 | + if ($compress) { |
|
| 711 | + $output .= '"t": "ship"'; |
|
| 712 | + } else { |
|
| 713 | + $output .= '"type": "ship"'; |
|
| 714 | + } |
|
| 546 | 715 | } else { |
| 547 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 548 | - else $output .= '"type": "aircraft"'; |
|
| 716 | + if ($compress) { |
|
| 717 | + $output .= '"t": "aircraft"'; |
|
| 718 | + } else { |
|
| 719 | + $output .= '"type": "aircraft"'; |
|
| 720 | + } |
|
| 549 | 721 | } |
| 550 | 722 | $output .= '},'; |
| 551 | 723 | $output .= '"geometry": {'; |
@@ -553,15 +725,19 @@ discard block |
||
| 553 | 725 | $output .= '"coordinates": ['; |
| 554 | 726 | if ($currenttime != '') { |
| 555 | 727 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 556 | - if (!isset($archivespeed)) $archivespeed = 1; |
|
| 728 | + if (!isset($archivespeed)) { |
|
| 729 | + $archivespeed = 1; |
|
| 730 | + } |
|
| 557 | 731 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
| 558 | 732 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 559 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
| 560 | - else { |
|
| 733 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 734 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
| 735 | + } else { |
|
| 561 | 736 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
| 562 | 737 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 563 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
| 564 | - else { |
|
| 738 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
| 739 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
| 740 | + } else { |
|
| 565 | 741 | $output .= $spotter_item['longitude'].', '; |
| 566 | 742 | $output .= $spotter_item['latitude']; |
| 567 | 743 | } |
@@ -639,7 +815,9 @@ discard block |
||
| 639 | 815 | } |
| 640 | 816 | */ |
| 641 | 817 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 642 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 818 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 819 | + $history = $_COOKIE['history']; |
|
| 820 | + } |
|
| 643 | 821 | |
| 644 | 822 | if ( |
| 645 | 823 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -709,8 +887,11 @@ discard block |
||
| 709 | 887 | $output_history .= ']}},'; |
| 710 | 888 | $output .= $output_history; |
| 711 | 889 | } |
| 712 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 713 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 890 | + if ($compress) { |
|
| 891 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 892 | + } else { |
|
| 893 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 894 | + } |
|
| 714 | 895 | } |
| 715 | 896 | $output_history .= '['; |
| 716 | 897 | $output_history .= $spotter_history['longitude'].', '; |
@@ -731,10 +912,15 @@ discard block |
||
| 731 | 912 | if ($d == false) { |
| 732 | 913 | if ($compress) { |
| 733 | 914 | $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",'; |
| 734 | - if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
| 735 | - elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
| 915 | + if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') { |
|
| 916 | + $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
| 917 | + } elseif (isset($spotter_history_array[0]['mapmatching_engine'])) { |
|
| 918 | + $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
| 919 | + } |
|
| 736 | 920 | $output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
| 737 | - } else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 921 | + } else { |
|
| 922 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 923 | + } |
|
| 738 | 924 | $d = true; |
| 739 | 925 | } |
| 740 | 926 | $output_history .= '['; |
@@ -757,7 +943,9 @@ discard block |
||
| 757 | 943 | $output_historyd = '['; |
| 758 | 944 | $output_historyd .= $spotter_item['longitude'].', '; |
| 759 | 945 | $output_historyd .= $spotter_item['latitude']; |
| 760 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 946 | + if (isset($spotter_history['altitude'])) { |
|
| 947 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 948 | + } |
|
| 761 | 949 | $output_historyd .= '],'; |
| 762 | 950 | //$output_history = $output_historyd.$output_history; |
| 763 | 951 | $output_history = $output_history.$output_historyd; |
@@ -784,8 +972,11 @@ discard block |
||
| 784 | 972 | && $spotter_item['arrival_airport'] != 'NA' |
| 785 | 973 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
| 786 | 974 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
| 787 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 788 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 975 | + if ($compress) { |
|
| 976 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 977 | + } else { |
|
| 978 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 979 | + } |
|
| 789 | 980 | if (isset($spotter_item['departure_airport_latitude'])) { |
| 790 | 981 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
| 791 | 982 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -818,8 +1009,11 @@ discard block |
||
| 818 | 1009 | || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
| 819 | 1010 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
| 820 | 1011 | $havedata = false; |
| 821 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 822 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 1012 | + if ($compress) { |
|
| 1013 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 1014 | + } else { |
|
| 1015 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 1016 | + } |
|
| 823 | 1017 | |
| 824 | 1018 | //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
| 825 | 1019 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -844,7 +1038,9 @@ discard block |
||
| 844 | 1038 | $output_dest = substr($output_dest, 0, -1); |
| 845 | 1039 | } |
| 846 | 1040 | $output_dest .= ']}},'; |
| 847 | - if ($havedata) $output .= $output_dest; |
|
| 1041 | + if ($havedata) { |
|
| 1042 | + $output .= $output_dest; |
|
| 1043 | + } |
|
| 848 | 1044 | unset($output_dest); |
| 849 | 1045 | } |
| 850 | 1046 | } |
@@ -852,7 +1048,9 @@ discard block |
||
| 852 | 1048 | $output .= ']'; |
| 853 | 1049 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 854 | 1050 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 855 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 1051 | + if (isset($begindate)) { |
|
| 1052 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 1053 | + } |
|
| 856 | 1054 | $output .= '"fc": "'.$j.'"'; |
| 857 | 1055 | } else { |
| 858 | 1056 | $output .= '"features": '; |