@@ -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) { |
@@ -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 | |
@@ -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 { |