@@ -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 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $real_arrival = $this->arrival($key); |
| 210 | 210 | $Spotter = new Spotter($this->db); |
| 211 | 211 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 212 | - $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']); |
|
| 212 | + $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 | 213 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | $send = false; |
| 243 | 243 | |
| 244 | 244 | // SBS format is CSV format |
| 245 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 245 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 246 | 246 | //print_r($line); |
| 247 | 247 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 248 | - 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)) { |
|
| 248 | + 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)) { |
|
| 249 | 249 | |
| 250 | 250 | // Increment message number |
| 251 | 251 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -278,25 +278,25 @@ discard block |
||
| 278 | 278 | if (!isset($this->all_flights[$id])) { |
| 279 | 279 | if ($globalDebug) echo 'New flight...'."\n"; |
| 280 | 280 | $this->all_flights[$id] = array(); |
| 281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 282 | - $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' => '')); |
|
| 283 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 282 | + $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' => '')); |
|
| 283 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 284 | 284 | if (!isset($line['id'])) { |
| 285 | 285 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 286 | 286 | // 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'))); |
| 287 | 287 | // 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'))); |
| 288 | - 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'))); |
|
| 288 | + 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'))); |
|
| 289 | 289 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 290 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 290 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 291 | 291 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 292 | 292 | } |
| 293 | 293 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 294 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 294 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | //print_r($this->all_flights); |
| 298 | 298 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 299 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 299 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 300 | 300 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 301 | 301 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 302 | 302 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -305,20 +305,20 @@ discard block |
||
| 305 | 305 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 306 | 306 | $Spotter = new Spotter($this->db); |
| 307 | 307 | if (isset($this->all_flights[$id]['source_type'])) { |
| 308 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 308 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 309 | 309 | } else { |
| 310 | 310 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 311 | 311 | } |
| 312 | 312 | $Spotter->db = null; |
| 313 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 314 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 313 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 314 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 318 | 318 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 319 | 319 | } |
| 320 | 320 | if (isset($line['id']) && !isset($line['hex'])) { |
| 321 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 321 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 322 | 322 | } |
| 323 | 323 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 324 | 324 | $icao = $line['aircraft_icao']; |
@@ -327,14 +327,14 @@ discard block |
||
| 327 | 327 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 328 | 328 | $Spotter->db = null; |
| 329 | 329 | } |
| 330 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 330 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 331 | 331 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 332 | 332 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 333 | 333 | // Get aircraft ICAO from aircraft name |
| 334 | 334 | $Spotter = new Spotter($this->db); |
| 335 | 335 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 336 | 336 | $Spotter->db = null; |
| 337 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 337 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -342,15 +342,15 @@ discard block |
||
| 342 | 342 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 343 | 343 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 344 | 344 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 345 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 345 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 346 | 346 | } |
| 347 | 347 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 349 | 349 | } |
| 350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 351 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 351 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 352 | 352 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 353 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 354 | 354 | } else { |
| 355 | 355 | 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"; |
| 356 | 356 | 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"; |
@@ -361,31 +361,31 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | return ''; |
| 363 | 363 | } |
| 364 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 364 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 366 | 366 | return ''; |
| 367 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 367 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 368 | 368 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 369 | 369 | return ''; |
| 370 | 370 | } elseif (!isset($line['datetime'])) { |
| 371 | 371 | date_default_timezone_set('UTC'); |
| 372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 373 | 373 | } else { |
| 374 | 374 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 375 | 375 | return ''; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 380 | 380 | } |
| 381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 383 | 383 | } |
| 384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 386 | 386 | } |
| 387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | 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'])) { |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 396 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 398 | - 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'))); |
|
| 399 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 400 | - 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'])); |
|
| 396 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 398 | + 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'))); |
|
| 399 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 400 | + 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'])); |
|
| 401 | 401 | } else { |
| 402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 403 | 403 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 404 | 404 | $timeelapsed = microtime(true); |
| 405 | 405 | $Spotter = new Spotter($this->db); |
@@ -409,13 +409,13 @@ discard block |
||
| 409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 414 | 414 | $Spotter->db = null; |
| 415 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 415 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 419 | 419 | |
| 420 | 420 | /* |
| 421 | 421 | if (!isset($line['id'])) { |
@@ -425,25 +425,25 @@ discard block |
||
| 425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 427 | 427 | */ |
| 428 | - 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'])); |
|
| 428 | + 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'])); |
|
| 429 | 429 | |
| 430 | 430 | //$putinarchive = true; |
| 431 | 431 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 432 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 432 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 433 | 433 | } |
| 434 | 434 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 435 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 435 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 436 | 436 | } |
| 437 | 437 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 438 | - $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' => '')); |
|
| 438 | + $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' => '')); |
|
| 439 | 439 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 440 | 440 | $timeelapsed = microtime(true); |
| 441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 442 | 442 | $Spotter = new Spotter($this->db); |
| 443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 445 | - $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' => '')); |
|
| 446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 445 | + $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' => '')); |
|
| 446 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 447 | 447 | } |
| 448 | 448 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 449 | 449 | $timeelapsed = microtime(true); |
@@ -457,35 +457,35 @@ discard block |
||
| 457 | 457 | $Translation->db = null; |
| 458 | 458 | } |
| 459 | 459 | $Spotter->db = null; |
| 460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 461 | 461 | } |
| 462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 463 | 463 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 464 | 464 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 465 | 465 | // $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'])); |
| 466 | - $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'])); |
|
| 466 | + $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'])); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
| 470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 471 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 471 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 480 | 480 | //$dataFound = true; |
| 481 | 481 | } 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'])) { |
| 482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 482 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 483 | 483 | if ($distance > 1000 && $distance < 10000) { |
| 484 | 484 | // use datetime |
| 485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 486 | 486 | $speed = $speed*3.6; |
| 487 | 487 | if ($speed < 1000) { |
| 488 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 488 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 489 | 489 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 490 | 490 | } else { |
| 491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 501 | 501 | return false; |
| 502 | 502 | } |
| 503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 504 | 504 | else unset($timediff); |
| 505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 506 | 506 | else unset($timediff_archive); |
| 507 | 507 | if ($this->tmd > 5 |
| 508 | 508 | || (isset($line['format_source']) |
@@ -527,14 +527,14 @@ discard block |
||
| 527 | 527 | || ($timediff > 30 |
| 528 | 528 | && isset($this->all_flights[$id]['latitude']) |
| 529 | 529 | && isset($this->all_flights[$id]['longitude']) |
| 530 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 530 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 531 | 531 | ) |
| 532 | 532 | ) { |
| 533 | 533 | |
| 534 | 534 | 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']))) { |
| 535 | 535 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 536 | 536 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 537 | - || !$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'])) { |
|
| 537 | + || !$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'])) { |
|
| 538 | 538 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 539 | 539 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 540 | 540 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | $timeelapsed = microtime(true); |
| 545 | 545 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 546 | 546 | $Spotter = new Spotter($this->db); |
| 547 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 547 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 548 | 548 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 549 | 549 | else $this->all_flights[$id]['over_country'] = ''; |
| 550 | 550 | $Spotter->db = null; |
| 551 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 551 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 552 | 552 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -574,13 +574,13 @@ discard block |
||
| 574 | 574 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 575 | 575 | } |
| 576 | 576 | //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)) { |
| 577 | - 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)) { |
|
| 577 | + 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)) { |
|
| 578 | 578 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 579 | 579 | $dataFound = true; |
| 580 | 580 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 581 | 581 | } |
| 582 | 582 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 584 | 584 | /* |
| 585 | 585 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 586 | 586 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -602,13 +602,13 @@ discard block |
||
| 602 | 602 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 603 | 603 | } |
| 604 | 604 | //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)) { |
| 605 | - 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)) { |
|
| 605 | + 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)) { |
|
| 606 | 606 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 607 | 607 | $dataFound = true; |
| 608 | 608 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 609 | 609 | } |
| 610 | 610 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 611 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 611 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 612 | 612 | /* |
| 613 | 613 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 614 | 614 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -626,46 +626,46 @@ discard block |
||
| 626 | 626 | } else if ($globalDebug && $timediff > 30) { |
| 627 | 627 | $this->tmd = $this->tmd + 1; |
| 628 | 628 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 629 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 630 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 629 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 630 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 631 | 631 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 635 | 635 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 637 | 637 | } |
| 638 | 638 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 639 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 639 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 640 | 640 | //$dataFound = true; |
| 641 | 641 | } |
| 642 | 642 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 644 | 644 | } |
| 645 | 645 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 647 | 647 | } |
| 648 | 648 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 650 | 650 | //$dataFound = true; |
| 651 | 651 | } |
| 652 | 652 | if (isset($line['ground']) && $line['ground'] != '') { |
| 653 | 653 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 654 | 654 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 656 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 657 | - 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'))); |
|
| 658 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 659 | - 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'])); |
|
| 655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 656 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 657 | + 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'))); |
|
| 658 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 659 | + 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'])); |
|
| 660 | 660 | } |
| 661 | 661 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 662 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 662 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 663 | 663 | //$dataFound = true; |
| 664 | 664 | } |
| 665 | 665 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 666 | 666 | 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'])) { |
| 667 | 667 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 669 | 669 | $highlight = ''; |
| 670 | 670 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 671 | 671 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -674,66 +674,66 @@ discard block |
||
| 674 | 674 | $timeelapsed = microtime(true); |
| 675 | 675 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 676 | 676 | $Spotter = new Spotter($this->db); |
| 677 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 677 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 678 | 678 | $Spotter->db = null; |
| 679 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 679 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 680 | 680 | } |
| 681 | 681 | //$putinarchive = true; |
| 682 | 682 | //$highlight = ''; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 685 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 686 | 686 | //$dataFound = true; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 690 | 690 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
| 691 | 691 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
| 692 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
| 692 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
| 693 | 693 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
| 694 | 694 | $line['altitude'] = $line['altitude'] - $geoid; |
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 698 | - 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; |
|
| 699 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 700 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 698 | + 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; |
|
| 699 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 700 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 701 | 701 | //$dataFound = true; |
| 702 | 702 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 703 | 703 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 704 | 704 | 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) { |
| 705 | 705 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 707 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 708 | - 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'))); |
|
| 709 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 710 | - 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'])); |
|
| 706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 707 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 708 | + 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'))); |
|
| 709 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 710 | + 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'])); |
|
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 713 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 717 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 717 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | if (isset($line['heading']) && $line['heading'] != '') { |
| 721 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 721 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 724 | 724 | //$dataFound = true; |
| 725 | 725 | } 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']) { |
| 726 | - $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']); |
|
| 727 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 728 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 726 | + $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']); |
|
| 727 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 728 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 729 | 729 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
| 730 | 730 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 731 | 731 | // If not enough messages and ACARS set heading to 0 |
| 732 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 732 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 733 | 733 | } |
| 734 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 735 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 736 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 734 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 735 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 736 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 737 | 737 | |
| 738 | 738 | // print_r($this->all_flights[$id]); |
| 739 | 739 | //gets the callsign from the last hour |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 745 | 745 | $this->all_flights[$id]['lastupdate'] = time(); |
| 746 | 746 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 747 | - 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'])) { |
|
| 747 | + 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'])) { |
|
| 748 | 748 | //print_r($this->all_flights); |
| 749 | 749 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 750 | 750 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -755,61 +755,61 @@ discard block |
||
| 755 | 755 | $SpotterLive = new SpotterLive($this->db); |
| 756 | 756 | 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')) { |
| 757 | 757 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 758 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 759 | 759 | } elseif (isset($line['id'])) { |
| 760 | 760 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 761 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 762 | 762 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 763 | 763 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 764 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 764 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 765 | 765 | } else $recent_ident = ''; |
| 766 | - $SpotterLive->db=null; |
|
| 766 | + $SpotterLive->db = null; |
|
| 767 | 767 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 768 | 768 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 769 | 769 | } else $recent_ident = ''; |
| 770 | 770 | } else { |
| 771 | 771 | $recent_ident = ''; |
| 772 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 772 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 773 | 773 | } |
| 774 | 774 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 775 | - if($recent_ident == "") |
|
| 775 | + if ($recent_ident == "") |
|
| 776 | 776 | { |
| 777 | 777 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 778 | 778 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 779 | 779 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 780 | 780 | //adds the spotter data for the archive |
| 781 | 781 | $ignoreImport = false; |
| 782 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 782 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 783 | 783 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 784 | 784 | $ignoreImport = true; |
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | if (count($globalAirportAccept) > 0) { |
| 788 | 788 | $ignoreImport = true; |
| 789 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 789 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 790 | 790 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 791 | 791 | $ignoreImport = false; |
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 796 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 797 | - 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)) { |
|
| 796 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 797 | + 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)) { |
|
| 798 | 798 | $ignoreImport = true; |
| 799 | 799 | } |
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 803 | 803 | $ignoreImport = true; |
| 804 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 805 | - 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)) { |
|
| 804 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 805 | + 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)) { |
|
| 806 | 806 | $ignoreImport = false; |
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 811 | 811 | $ignoreImport = true; |
| 812 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 812 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 813 | 813 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 814 | 814 | $ignoreImport = false; |
| 815 | 815 | } |
@@ -821,32 +821,32 @@ discard block |
||
| 821 | 821 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 822 | 822 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 823 | 823 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 824 | - 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'))); |
|
| 824 | + 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'))); |
|
| 825 | 825 | $timeelapsed = microtime(true); |
| 826 | 826 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 827 | 827 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 828 | 828 | $Spotter = new Spotter($this->db); |
| 829 | - $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']); |
|
| 829 | + $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']); |
|
| 830 | 830 | $Spotter->db = null; |
| 831 | 831 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 834 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 835 | 835 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 836 | 836 | |
| 837 | 837 | // Add source stat in DB |
| 838 | 838 | $Stats = new Stats($this->db); |
| 839 | 839 | if (!empty($this->stats)) { |
| 840 | 840 | if ($globalDebug) echo 'Add source stats : '; |
| 841 | - foreach($this->stats as $date => $data) { |
|
| 842 | - foreach($data as $source => $sourced) { |
|
| 841 | + foreach ($this->stats as $date => $data) { |
|
| 842 | + foreach ($data as $source => $sourced) { |
|
| 843 | 843 | //print_r($sourced); |
| 844 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 845 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 844 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 845 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 846 | 846 | if (isset($sourced['msg'])) { |
| 847 | 847 | if (time() - $sourced['msg']['date'] > 10) { |
| 848 | 848 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 849 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 849 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 850 | 850 | unset($this->stats[$date][$source]['msg']); |
| 851 | 851 | } |
| 852 | 852 | } |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 885 | 885 | $SpotterLive = new SpotterLive($this->db); |
| 886 | 886 | $SpotterLive->deleteLiveSpotterData(); |
| 887 | - $SpotterLive->db=null; |
|
| 887 | + $SpotterLive->db = null; |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | if ($globalDebug) echo " Done\n"; |
| 891 | 891 | $this->last_delete = time(); |
| 892 | 892 | } |
| 893 | 893 | } else { |
| 894 | - 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')) { |
|
| 894 | + 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')) { |
|
| 895 | 895 | $this->all_flights[$id]['id'] = $recent_ident; |
| 896 | 896 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 897 | 897 | } |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 900 | 900 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 901 | 901 | $Spotter = new Spotter($this->db); |
| 902 | - $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']); |
|
| 902 | + $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']); |
|
| 903 | 903 | $Spotter->db = null; |
| 904 | 904 | } |
| 905 | 905 | } |
@@ -925,37 +925,37 @@ discard block |
||
| 925 | 925 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 926 | 926 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 927 | 927 | |
| 928 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 928 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 929 | 929 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 930 | 930 | $ignoreImport = true; |
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | if (count($globalAirportAccept) > 0) { |
| 934 | 934 | $ignoreImport = true; |
| 935 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 935 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 936 | 936 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 937 | 937 | $ignoreImport = false; |
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 942 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 943 | - 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)) { |
|
| 942 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 943 | + 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)) { |
|
| 944 | 944 | $ignoreImport = true; |
| 945 | 945 | } |
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 949 | 949 | $ignoreImport = true; |
| 950 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 951 | - 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)) { |
|
| 950 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 951 | + 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)) { |
|
| 952 | 952 | $ignoreImport = false; |
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | } |
| 956 | 956 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 957 | 957 | $ignoreImport = true; |
| 958 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 958 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 959 | 959 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 960 | 960 | $ignoreImport = false; |
| 961 | 961 | } |
@@ -963,23 +963,23 @@ discard block |
||
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | if (!$ignoreImport) { |
| 966 | - 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'])) { |
|
| 967 | - 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'))); |
|
| 966 | + 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'])) { |
|
| 967 | + 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'))); |
|
| 968 | 968 | $timeelapsed = microtime(true); |
| 969 | 969 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 970 | 970 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 971 | 971 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 972 | 972 | $SpotterLive = new SpotterLive($this->db); |
| 973 | - $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']); |
|
| 973 | + $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']); |
|
| 974 | 974 | $SpotterLive->db = null; |
| 975 | 975 | if ($globalDebug) echo $result."\n"; |
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 979 | - $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']); |
|
| 979 | + $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']); |
|
| 980 | 980 | } |
| 981 | 981 | $this->all_flights[$id]['putinarchive'] = false; |
| 982 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 982 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 983 | 983 | |
| 984 | 984 | // Put statistics in $this->stats variable |
| 985 | 985 | //if ($line['format_source'] != 'aprs') { |
@@ -998,19 +998,19 @@ discard block |
||
| 998 | 998 | $latitude = $globalCenterLatitude; |
| 999 | 999 | $longitude = $globalCenterLongitude; |
| 1000 | 1000 | } |
| 1001 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 1001 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 1002 | 1002 | } else { |
| 1003 | 1003 | $latitude = $this->source_location[$source]['latitude']; |
| 1004 | 1004 | $longitude = $this->source_location[$source]['longitude']; |
| 1005 | 1005 | } |
| 1006 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1006 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1007 | 1007 | //$stats_heading = $stats_heading%22.5; |
| 1008 | 1008 | $stats_heading = round($stats_heading/22.5); |
| 1009 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1009 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1010 | 1010 | $current_date = date('Y-m-d'); |
| 1011 | 1011 | if ($stats_heading == 16) $stats_heading = 0; |
| 1012 | 1012 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1013 | - for ($i=0;$i<=15;$i++) { |
|
| 1013 | + for ($i = 0; $i <= 15; $i++) { |
|
| 1014 | 1014 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 1015 | 1015 | } |
| 1016 | 1016 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1025,9 +1025,9 @@ discard block |
||
| 1025 | 1025 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1026 | 1026 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1027 | 1027 | end($this->stats[$current_date][$source]['hist']); |
| 1028 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1028 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1029 | 1029 | } else $mini = 0; |
| 1030 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1030 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1031 | 1031 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1032 | 1032 | } |
| 1033 | 1033 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1041 | 1041 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1042 | 1042 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1043 | - } 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"; |
|
| 1043 | + } 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"; |
|
| 1044 | 1044 | //$this->del(); |
| 1045 | 1045 | |
| 1046 | 1046 | 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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'; |
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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'"; |
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 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 | |
@@ -14,75 +14,75 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
| 23 | 23 | } else { |
| 24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if (isset($filter[0]['source'])) { |
| 28 | - $filters = array_merge($filters,$filter); |
|
| 28 | + $filters = array_merge($filters, $filter); |
|
| 29 | 29 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | - foreach($filters as $flt) { |
|
| 33 | + foreach ($filters as $flt) { |
|
| 34 | 34 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 35 | 35 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
| 36 | 36 | if (isset($flt['source'])) { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | 38 | } else { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | 71 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
| 72 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | 82 | if (count($filter['source']) == 1) { |
| 83 | 83 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
| 84 | 84 | } else { |
| 85 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 85 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $filter_query_where .= " AND flightaware_id = '".$filter['id']."'"; |
| 93 | 93 | } |
| 94 | 94 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 95 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 95 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 96 | 96 | } |
| 97 | 97 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 98 | 98 | $filter_query_date = ''; |
@@ -117,41 +117,41 @@ discard block |
||
| 117 | 117 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 120 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 121 | 121 | } |
| 122 | 122 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 123 | 123 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 124 | 124 | if ($filter_query_where != '') { |
| 125 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 125 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 126 | 126 | } |
| 127 | 127 | $filter_query = $filter_query_join.$filter_query_where; |
| 128 | 128 | return $filter_query; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Spotter_archive |
| 132 | - public function 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 132 | + public function 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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 133 | 133 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 134 | 134 | if ($over_country == '') { |
| 135 | 135 | $Spotter = new Spotter($this->db); |
| 136 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 136 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 137 | 137 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 138 | 138 | else $country = ''; |
| 139 | 139 | } else $country = $over_country; |
| 140 | - if ($airline_type === NULL) $airline_type =''; |
|
| 140 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 141 | 141 | |
| 142 | 142 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 143 | 143 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 144 | 144 | |
| 145 | 145 | // Route is not added in spotter_archive |
| 146 | - $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 146 | + $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 147 | 147 | VALUES (: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, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 148 | 148 | |
| 149 | - $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 149 | + $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 150 | 150 | try { |
| 151 | 151 | $sth = $this->db->prepare($query); |
| 152 | 152 | $sth->execute($query_values); |
| 153 | 153 | $sth->closeCursor(); |
| 154 | - } catch(PDOException $e) { |
|
| 154 | + } catch (PDOException $e) { |
|
| 155 | 155 | return "error : ".$e->getMessage(); |
| 156 | 156 | } |
| 157 | 157 | return "success"; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 173 | 173 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 174 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 174 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 175 | 175 | |
| 176 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 176 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 177 | 177 | |
| 178 | 178 | return $spotter_array; |
| 179 | 179 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 193 | 193 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 194 | 194 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 195 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 195 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 196 | 196 | |
| 197 | 197 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 198 | 198 | /* |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 207 | 207 | */ |
| 208 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 208 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 209 | 209 | |
| 210 | 210 | return $spotter_array; |
| 211 | 211 | } |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | date_default_timezone_set('UTC'); |
| 222 | 222 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 223 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 223 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 224 | 224 | |
| 225 | 225 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | 228 | $sth = $this->db->prepare($query); |
| 229 | 229 | $sth->execute(array(':id' => $id)); |
| 230 | - } catch(PDOException $e) { |
|
| 230 | + } catch (PDOException $e) { |
|
| 231 | 231 | echo $e->getMessage(); |
| 232 | 232 | die; |
| 233 | 233 | } |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | date_default_timezone_set('UTC'); |
| 248 | 248 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 249 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 249 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 250 | 250 | |
| 251 | 251 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 252 | 252 | |
| 253 | 253 | try { |
| 254 | 254 | $sth = $this->db->prepare($query); |
| 255 | 255 | $sth->execute(array(':id' => $id)); |
| 256 | - } catch(PDOException $e) { |
|
| 256 | + } catch (PDOException $e) { |
|
| 257 | 257 | echo $e->getMessage(); |
| 258 | 258 | die; |
| 259 | 259 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | date_default_timezone_set('UTC'); |
| 276 | 276 | |
| 277 | 277 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 278 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 278 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | $sth = $this->db->prepare($query); |
| 282 | 282 | $sth->execute(array(':ident' => $ident)); |
| 283 | - } catch(PDOException $e) { |
|
| 283 | + } catch (PDOException $e) { |
|
| 284 | 284 | echo $e->getMessage(); |
| 285 | 285 | die; |
| 286 | 286 | } |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | date_default_timezone_set('UTC'); |
| 302 | 302 | |
| 303 | 303 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 304 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 304 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 305 | 305 | |
| 306 | 306 | try { |
| 307 | 307 | $sth = $this->db->prepare($query); |
| 308 | 308 | $sth->execute(array(':id' => $id)); |
| 309 | - } catch(PDOException $e) { |
|
| 309 | + } catch (PDOException $e) { |
|
| 310 | 310 | echo $e->getMessage(); |
| 311 | 311 | die; |
| 312 | 312 | } |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | { |
| 326 | 326 | date_default_timezone_set('UTC'); |
| 327 | 327 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 328 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 328 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 329 | 329 | try { |
| 330 | 330 | $sth = $this->db->prepare($query); |
| 331 | 331 | $sth->execute(array(':id' => $id)); |
| 332 | - } catch(PDOException $e) { |
|
| 332 | + } catch (PDOException $e) { |
|
| 333 | 333 | echo $e->getMessage(); |
| 334 | 334 | die; |
| 335 | 335 | } |
@@ -347,12 +347,12 @@ discard block |
||
| 347 | 347 | { |
| 348 | 348 | date_default_timezone_set('UTC'); |
| 349 | 349 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 350 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 350 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 351 | 351 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 352 | 352 | try { |
| 353 | 353 | $sth = $this->db->prepare($query); |
| 354 | 354 | $sth->execute(array(':ident' => $ident)); |
| 355 | - } catch(PDOException $e) { |
|
| 355 | + } catch (PDOException $e) { |
|
| 356 | 356 | echo $e->getMessage(); |
| 357 | 357 | die; |
| 358 | 358 | } |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | * @return Array the spotter information |
| 369 | 369 | * |
| 370 | 370 | */ |
| 371 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 371 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 372 | 372 | { |
| 373 | 373 | $Spotter = new Spotter($this->db); |
| 374 | 374 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 375 | - $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 376 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 375 | + $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 376 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 377 | 377 | return $spotter_array; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo $e->getMessage(); |
| 393 | 393 | die; |
| 394 | 394 | } |
@@ -400,24 +400,24 @@ discard block |
||
| 400 | 400 | * @return Array the spotter information |
| 401 | 401 | * |
| 402 | 402 | */ |
| 403 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 403 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 404 | 404 | { |
| 405 | 405 | global $globalDBdriver, $globalLiveInterval; |
| 406 | 406 | date_default_timezone_set('UTC'); |
| 407 | 407 | |
| 408 | 408 | $filter_query = ''; |
| 409 | 409 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 410 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 410 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 411 | 411 | } |
| 412 | 412 | // Use spotter_output also ? |
| 413 | 413 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 414 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 414 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 415 | 415 | } |
| 416 | 416 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 417 | 417 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 418 | 418 | } |
| 419 | 419 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 420 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 420 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -436,14 +436,14 @@ discard block |
||
| 436 | 436 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 437 | 437 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 438 | 438 | */ |
| 439 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 439 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 440 | 440 | FROM spotter_archive |
| 441 | 441 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 442 | 442 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 443 | 443 | '.$filter_query.' ORDER BY flightaware_id'; |
| 444 | 444 | } else { |
| 445 | 445 | //$query = '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, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 446 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 447 | 447 | FROM spotter_archive |
| 448 | 448 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 449 | 449 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | try { |
| 454 | 454 | $sth = $this->db->prepare($query); |
| 455 | 455 | $sth->execute(); |
| 456 | - } catch(PDOException $e) { |
|
| 456 | + } catch (PDOException $e) { |
|
| 457 | 457 | echo $e->getMessage(); |
| 458 | 458 | die; |
| 459 | 459 | } |
@@ -468,24 +468,24 @@ discard block |
||
| 468 | 468 | * @return Array the spotter information |
| 469 | 469 | * |
| 470 | 470 | */ |
| 471 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 471 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 472 | 472 | { |
| 473 | 473 | global $globalDBdriver, $globalLiveInterval; |
| 474 | 474 | date_default_timezone_set('UTC'); |
| 475 | 475 | |
| 476 | 476 | $filter_query = ''; |
| 477 | 477 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 478 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 478 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 479 | 479 | } |
| 480 | 480 | // Should use spotter_output also ? |
| 481 | 481 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 482 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 482 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 483 | 483 | } |
| 484 | 484 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 485 | 485 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 486 | 486 | } |
| 487 | 487 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 488 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 488 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | FROM spotter_archive |
| 496 | 496 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 497 | 497 | */ |
| 498 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 498 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 499 | 499 | FROM spotter_archive_output |
| 500 | 500 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 501 | 501 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 511 | 511 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 512 | 512 | */ |
| 513 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 513 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 514 | 514 | FROM spotter_archive_output |
| 515 | 515 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 516 | 516 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | try { |
| 523 | 523 | $sth = $this->db->prepare($query); |
| 524 | 524 | $sth->execute(); |
| 525 | - } catch(PDOException $e) { |
|
| 525 | + } catch (PDOException $e) { |
|
| 526 | 526 | echo $e->getMessage(); |
| 527 | 527 | die; |
| 528 | 528 | } |
@@ -537,23 +537,23 @@ discard block |
||
| 537 | 537 | * @return Array the spotter information |
| 538 | 538 | * |
| 539 | 539 | */ |
| 540 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 540 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 541 | 541 | { |
| 542 | 542 | global $globalDBdriver, $globalLiveInterval; |
| 543 | 543 | date_default_timezone_set('UTC'); |
| 544 | 544 | |
| 545 | 545 | $filter_query = ''; |
| 546 | 546 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 547 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 547 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 548 | 548 | } |
| 549 | 549 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 550 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 550 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 551 | 551 | } |
| 552 | 552 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 553 | 553 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 556 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 556 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | try { |
| 569 | 569 | $sth = $this->db->prepare($query); |
| 570 | 570 | $sth->execute(); |
| 571 | - } catch(PDOException $e) { |
|
| 571 | + } catch (PDOException $e) { |
|
| 572 | 572 | echo $e->getMessage(); |
| 573 | 573 | die; |
| 574 | 574 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @return Array the spotter information |
| 589 | 589 | * |
| 590 | 590 | */ |
| 591 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 591 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 592 | 592 | { |
| 593 | 593 | global $globalTimezone, $globalDBdriver; |
| 594 | 594 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | |
| 611 | 611 | $q_array = explode(" ", $q); |
| 612 | 612 | |
| 613 | - foreach ($q_array as $q_item){ |
|
| 613 | + foreach ($q_array as $q_item) { |
|
| 614 | 614 | $additional_query .= " AND ("; |
| 615 | 615 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 616 | 616 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | if ($registration != "") |
| 644 | 644 | { |
| 645 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 645 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 646 | 646 | if (!is_string($registration)) |
| 647 | 647 | { |
| 648 | 648 | return false; |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | if ($aircraft_icao != "") |
| 655 | 655 | { |
| 656 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 656 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 657 | 657 | if (!is_string($aircraft_icao)) |
| 658 | 658 | { |
| 659 | 659 | return false; |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | |
| 665 | 665 | if ($aircraft_manufacturer != "") |
| 666 | 666 | { |
| 667 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 667 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 668 | 668 | if (!is_string($aircraft_manufacturer)) |
| 669 | 669 | { |
| 670 | 670 | return false; |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | if ($airline_icao != "") |
| 687 | 687 | { |
| 688 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 688 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 689 | 689 | if (!is_string($airline_icao)) |
| 690 | 690 | { |
| 691 | 691 | return false; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | if ($airline_country != "") |
| 698 | 698 | { |
| 699 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 699 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 700 | 700 | if (!is_string($airline_country)) |
| 701 | 701 | { |
| 702 | 702 | return false; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | if ($airline_type != "") |
| 709 | 709 | { |
| 710 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 710 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 711 | 711 | if (!is_string($airline_type)) |
| 712 | 712 | { |
| 713 | 713 | return false; |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | if ($airport != "") |
| 731 | 731 | { |
| 732 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 732 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 733 | 733 | if (!is_string($airport)) |
| 734 | 734 | { |
| 735 | 735 | return false; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | if ($airport_country != "") |
| 742 | 742 | { |
| 743 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 743 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 744 | 744 | if (!is_string($airport_country)) |
| 745 | 745 | { |
| 746 | 746 | return false; |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | if ($callsign != "") |
| 753 | 753 | { |
| 754 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 754 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 755 | 755 | if (!is_string($callsign)) |
| 756 | 756 | { |
| 757 | 757 | return false; |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | $translate = $Translation->ident2icao($callsign); |
| 760 | 760 | if ($translate != $callsign) { |
| 761 | 761 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 762 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 762 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 763 | 763 | } else { |
| 764 | 764 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 765 | 765 | } |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($owner != "") |
| 770 | 770 | { |
| 771 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 771 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($owner)) |
| 773 | 773 | { |
| 774 | 774 | return false; |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($pilot_name != "") |
| 781 | 781 | { |
| 782 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 782 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 783 | 783 | if (!is_string($pilot_name)) |
| 784 | 784 | { |
| 785 | 785 | return false; |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | |
| 791 | 791 | if ($pilot_id != "") |
| 792 | 792 | { |
| 793 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 793 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 794 | 794 | if (!is_string($pilot_id)) |
| 795 | 795 | { |
| 796 | 796 | return false; |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | if ($departure_airport_route != "") |
| 803 | 803 | { |
| 804 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 804 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 805 | 805 | if (!is_string($departure_airport_route)) |
| 806 | 806 | { |
| 807 | 807 | return false; |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | |
| 813 | 813 | if ($arrival_airport_route != "") |
| 814 | 814 | { |
| 815 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 815 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 816 | 816 | if (!is_string($arrival_airport_route)) |
| 817 | 817 | { |
| 818 | 818 | return false; |
@@ -825,8 +825,8 @@ discard block |
||
| 825 | 825 | { |
| 826 | 826 | $altitude_array = explode(",", $altitude); |
| 827 | 827 | |
| 828 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 828 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | 830 | |
| 831 | 831 | |
| 832 | 832 | if ($altitude_array[1] != "") |
@@ -843,8 +843,8 @@ discard block |
||
| 843 | 843 | if ($date_posted != "") |
| 844 | 844 | { |
| 845 | 845 | $date_array = explode(",", $date_posted); |
| 846 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 847 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 846 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 847 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 848 | 848 | if ($globalTimezone != '') { |
| 849 | 849 | date_default_timezone_set($globalTimezone); |
| 850 | 850 | $datetime = new DateTime(); |
@@ -871,8 +871,8 @@ discard block |
||
| 871 | 871 | if ($limit != "") |
| 872 | 872 | { |
| 873 | 873 | $limit_array = explode(",", $limit); |
| 874 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 875 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 874 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 875 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 876 | 876 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 877 | 877 | { |
| 878 | 878 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -880,8 +880,8 @@ discard block |
||
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 883 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 884 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 883 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 884 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 885 | 885 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 886 | 886 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 887 | 887 | } else { |
@@ -897,12 +897,12 @@ discard block |
||
| 897 | 897 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 900 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 901 | 901 | WHERE spotter_archive_output.ident <> '' |
| 902 | 902 | ".$additional_query." |
| 903 | 903 | ".$filter_query.$orderby_query; |
| 904 | 904 | } |
| 905 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 905 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 906 | 906 | return $spotter_array; |
| 907 | 907 | } |
| 908 | 908 | |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | try { |
| 918 | 918 | $sth = $this->db->prepare($query); |
| 919 | 919 | $sth->execute(); |
| 920 | - } catch(PDOException $e) { |
|
| 920 | + } catch (PDOException $e) { |
|
| 921 | 921 | return "error"; |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -954,8 +954,8 @@ discard block |
||
| 954 | 954 | { |
| 955 | 955 | $limit_array = explode(",", $limit); |
| 956 | 956 | |
| 957 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 958 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 957 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 958 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 959 | 959 | |
| 960 | 960 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 961 | 961 | { |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | $query_values = array(); |
| 997 | 997 | $limit_query = ''; |
| 998 | 998 | $additional_query = ''; |
| 999 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 999 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1000 | 1000 | |
| 1001 | 1001 | if ($owner != "") |
| 1002 | 1002 | { |
@@ -1013,8 +1013,8 @@ discard block |
||
| 1013 | 1013 | { |
| 1014 | 1014 | $limit_array = explode(",", $limit); |
| 1015 | 1015 | |
| 1016 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1016 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1020 | 1020 | { |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | $query_values = array(); |
| 1055 | 1055 | $limit_query = ''; |
| 1056 | 1056 | $additional_query = ''; |
| 1057 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1057 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1058 | 1058 | |
| 1059 | 1059 | if ($pilot != "") |
| 1060 | 1060 | { |
@@ -1066,8 +1066,8 @@ discard block |
||
| 1066 | 1066 | { |
| 1067 | 1067 | $limit_array = explode(",", $limit); |
| 1068 | 1068 | |
| 1069 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1070 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1070 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1071 | 1071 | |
| 1072 | 1072 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1073 | 1073 | { |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | * @return Array the airline country list |
| 1098 | 1098 | * |
| 1099 | 1099 | */ |
| 1100 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1100 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1101 | 1101 | { |
| 1102 | 1102 | global $globalDBdriver; |
| 1103 | 1103 | /* |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | $flight_array = array(); |
| 1127 | 1127 | $temp_array = array(); |
| 1128 | 1128 | |
| 1129 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1129 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | $temp_array['flight_count'] = $row['nb']; |
| 1132 | 1132 | $temp_array['flight_country'] = $row['name']; |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | * @return Array the airline country list |
| 1144 | 1144 | * |
| 1145 | 1145 | */ |
| 1146 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1146 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1147 | 1147 | { |
| 1148 | 1148 | global $globalDBdriver; |
| 1149 | 1149 | /* |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | $flight_array = array(); |
| 1173 | 1173 | $temp_array = array(); |
| 1174 | 1174 | |
| 1175 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1175 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1176 | 1176 | { |
| 1177 | 1177 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1178 | 1178 | $temp_array['flight_count'] = $row['nb']; |
@@ -1190,14 +1190,14 @@ discard block |
||
| 1190 | 1190 | * @return Array the spotter information |
| 1191 | 1191 | * |
| 1192 | 1192 | */ |
| 1193 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1193 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | $Spotter = new Spotter($this->db); |
| 1196 | 1196 | date_default_timezone_set('UTC'); |
| 1197 | 1197 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1198 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1199 | - $date = date('c',$date); |
|
| 1200 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1198 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1199 | + $date = date('c', $date); |
|
| 1200 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1201 | 1201 | return $spotter_array; |
| 1202 | 1202 | } |
| 1203 | 1203 | |
@@ -1207,14 +1207,14 @@ discard block |
||
| 1207 | 1207 | * @return Array the spotter information |
| 1208 | 1208 | * |
| 1209 | 1209 | */ |
| 1210 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1210 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1211 | 1211 | { |
| 1212 | 1212 | $Spotter = new Spotter($this->db); |
| 1213 | 1213 | date_default_timezone_set('UTC'); |
| 1214 | 1214 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1215 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1216 | - $date = date('c',$date); |
|
| 1217 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1215 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1216 | + $date = date('c', $date); |
|
| 1217 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1218 | 1218 | return $spotter_array; |
| 1219 | 1219 | } |
| 1220 | 1220 | |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | * @return Array the spotter information |
| 1225 | 1225 | * |
| 1226 | 1226 | */ |
| 1227 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1227 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1228 | 1228 | { |
| 1229 | 1229 | global $global_query; |
| 1230 | 1230 | $Spotter = new Spotter($this->db); |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | $query_values = array(); |
| 1233 | 1233 | $limit_query = ''; |
| 1234 | 1234 | $additional_query = ''; |
| 1235 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1235 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1236 | 1236 | |
| 1237 | 1237 | if ($airport != "") |
| 1238 | 1238 | { |
@@ -1249,8 +1249,8 @@ discard block |
||
| 1249 | 1249 | { |
| 1250 | 1250 | $limit_array = explode(",", $limit); |
| 1251 | 1251 | |
| 1252 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1253 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1252 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1253 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1254 | 1254 | |
| 1255 | 1255 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1256 | 1256 | { |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $s3 = sin($bank/2); |
| 60 | 60 | $c1c2 = $c1*$c2; |
| 61 | 61 | $s1s2 = $s1*$s2; |
| 62 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
| 63 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
| 64 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 65 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 66 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
| 62 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
| 63 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
| 64 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 65 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 66 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
| 67 | 67 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
| 68 | 68 | |
| 69 | 69 | } |
@@ -84,17 +84,17 @@ discard block |
||
| 84 | 84 | $min = false; |
| 85 | 85 | $allhistory = false; |
| 86 | 86 | $filter['source'] = array(); |
| 87 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 88 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 89 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 90 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 91 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 92 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 93 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
| 94 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 95 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 96 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 97 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 87 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 88 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 90 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 91 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 92 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 93 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
| 94 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 95 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 96 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 97 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 98 | 98 | /* |
| 99 | 99 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 100 | 100 | $min = true; |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | $from_archive = true; |
| 142 | 142 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 143 | 143 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 144 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 145 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 146 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 148 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 149 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
| 144 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 145 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 146 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 148 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 149 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
| 150 | 150 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
| 151 | 151 | $from_archive = true; |
| 152 | 152 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -156,55 +156,55 @@ discard block |
||
| 156 | 156 | $begindate = $_COOKIE['archive_begin']; |
| 157 | 157 | $enddate = $_COOKIE['archive_end']; |
| 158 | 158 | |
| 159 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
| 160 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 161 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 159 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
| 160 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 161 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 162 | 162 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
| 163 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 163 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 164 | 164 | } elseif ($tracker) { |
| 165 | 165 | $coord = array(); |
| 166 | 166 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
| 167 | - $coord = explode(',',$_GET['coord']); |
|
| 168 | - 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) |
|
| 167 | + $coord = explode(',', $_GET['coord']); |
|
| 168 | + 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) |
|
| 169 | 169 | && $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)) { |
| 170 | 170 | $coord = array(); |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true); |
|
| 173 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true); |
|
| 174 | 174 | } elseif ($marine) { |
| 175 | 175 | $coord = array(); |
| 176 | 176 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
| 177 | - $coord = explode(',',$_GET['coord']); |
|
| 178 | - 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) |
|
| 177 | + $coord = explode(',', $_GET['coord']); |
|
| 178 | + 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) |
|
| 179 | 179 | && $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)) { |
| 180 | 180 | $coord = array(); |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true); |
|
| 183 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true); |
|
| 184 | 184 | } else { |
| 185 | 185 | $coord = array(); |
| 186 | 186 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
| 187 | - $coord = explode(',',$_GET['coord']); |
|
| 188 | - 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) |
|
| 187 | + $coord = explode(',', $_GET['coord']); |
|
| 188 | + 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) |
|
| 189 | 189 | && $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)) { |
| 190 | 190 | $coord = array(); |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | $previous_filter = $filter; |
| 194 | 194 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) { |
| 195 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrack'])); |
|
| 196 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
| 195 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrack'])); |
|
| 196 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
| 197 | 197 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) { |
| 198 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true,$_COOKIE['MapTrack']); |
|
| 198 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true, $_COOKIE['MapTrack']); |
|
| 199 | 199 | } else { |
| 200 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
| 200 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
| 201 | 201 | } |
| 202 | 202 | $filter = $previous_filter; |
| 203 | 203 | } |
| 204 | 204 | //print_r($spotter_array); |
| 205 | 205 | if (!empty($spotter_array) && isset($coord)) { |
| 206 | 206 | if (isset($_GET['archive'])) { |
| 207 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 207 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 208 | 208 | } elseif ($tracker) { |
| 209 | 209 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
| 210 | 210 | } elseif ($marine) { |
@@ -215,17 +215,17 @@ discard block |
||
| 215 | 215 | if ($flightcnt == '') $flightcnt = 0; |
| 216 | 216 | } else $flightcnt = 0; |
| 217 | 217 | |
| 218 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 218 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 219 | 219 | $minitime = time(); |
| 220 | 220 | $minitracktime_begin = time(); |
| 221 | 221 | $minitracktime = $minitracktime_begin; |
| 222 | 222 | $maxitime = 0; |
| 223 | -$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT); |
|
| 223 | +$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT); |
|
| 224 | 224 | $modelsdb = array(); |
| 225 | 225 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
| 226 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
| 227 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
| 228 | - if (isset($row[1]) ){ |
|
| 226 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
| 227 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
| 228 | + if (isset($row[1])) { |
|
| 229 | 229 | $model = $row[0]; |
| 230 | 230 | $modelsdb[$model] = $row[1]; |
| 231 | 231 | } |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | $modelsdb2 = array(); |
| 237 | 237 | if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) { |
| 238 | - if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) { |
|
| 239 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
| 240 | - if (isset($row[1]) ){ |
|
| 238 | + if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) { |
|
| 239 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
| 240 | + if (isset($row[1])) { |
|
| 241 | 241 | $model = $row[0]; |
| 242 | 242 | $modelsdb2[$model] = $row[1]; |
| 243 | 243 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 276 | 276 | { |
| 277 | 277 | $nblatlong = 0; |
| 278 | - foreach($spotter_array as $spotter_item) |
|
| 278 | + foreach ($spotter_array as $spotter_item) |
|
| 279 | 279 | { |
| 280 | 280 | $j++; |
| 281 | 281 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | $output .= '"lastupdate": "'.$lastupdate.'",'; |
| 318 | 318 | if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",'; |
| 319 | 319 | if ($tracker) { |
| 320 | - $output.= '"type": "tracker"'; |
|
| 320 | + $output .= '"type": "tracker"'; |
|
| 321 | 321 | } elseif ($marine) { |
| 322 | - $output.= '"type": "marine"'; |
|
| 322 | + $output .= '"type": "marine"'; |
|
| 323 | 323 | } else { |
| 324 | 324 | if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) { |
| 325 | 325 | $aircraft_icao = $spotter_item['aircraft_icao']; |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | if (isset($airline_icao)) { |
| 334 | 334 | $imagefile = $aircraft_icao.'-'.$airline_icao.'.png'; |
| 335 | 335 | if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) { |
| 336 | - $output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
| 336 | + $output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - if ($ident != '') $output.= '"ident": "'.$ident.'",'; |
|
| 340 | + if ($ident != '') $output .= '"ident": "'.$ident.'",'; |
|
| 341 | 341 | } |
| 342 | - $output.= '"gltf2": %gltf2%,'; |
|
| 343 | - $output.= '"type": "flight"'; |
|
| 342 | + $output .= '"gltf2": %gltf2%,'; |
|
| 343 | + $output .= '"type": "flight"'; |
|
| 344 | 344 | } |
| 345 | 345 | $output .= '},'; |
| 346 | 346 | |
@@ -693,8 +693,8 @@ discard block |
||
| 693 | 693 | $output .= '},'; |
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
| 697 | - else $output = str_replace('%onground%','false',$output); |
|
| 696 | + if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output); |
|
| 697 | + else $output = str_replace('%onground%', 'false', $output); |
|
| 698 | 698 | |
| 699 | 699 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
| 700 | 700 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
| 711 | 711 | if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']); |
| 712 | 712 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 713 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 713 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 714 | 714 | $output .= $spotter_item['longitude'].', '; |
| 715 | 715 | $output .= $spotter_item['latitude']; |
| 716 | 716 | $prevlong = $spotter_item['longitude']; |
@@ -738,8 +738,8 @@ discard block |
||
| 738 | 738 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 739 | 739 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 740 | 740 | } else { |
| 741 | - $nblatlong = $nblatlong+1; |
|
| 742 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 741 | + $nblatlong = $nblatlong + 1; |
|
| 742 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 743 | 743 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 744 | 744 | if ($spotter_item['ground_speed'] == 0) { |
| 745 | 745 | $output .= $prevlong.', '; |
@@ -779,21 +779,21 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | $output .= ']'; |
| 781 | 781 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 782 | - if ((time()-$globalLiveInterval) > $minitime) { |
|
| 783 | - if (time()-$globalLiveInterval > $maxitime) { |
|
| 784 | - $output = str_replace('%minitime%',date("c",$maxitime),$output); |
|
| 782 | + if ((time() - $globalLiveInterval) > $minitime) { |
|
| 783 | + if (time() - $globalLiveInterval > $maxitime) { |
|
| 784 | + $output = str_replace('%minitime%', date("c", $maxitime), $output); |
|
| 785 | 785 | } else { |
| 786 | - $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 786 | + $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 789 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 790 | 790 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) { |
| 791 | - $output = str_replace('%minitime%',date("c",$minitracktime),$output); |
|
| 791 | + $output = str_replace('%minitime%', date("c", $minitracktime), $output); |
|
| 792 | 792 | } else { |
| 793 | - $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 793 | + $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 794 | 794 | } |
| 795 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
| 796 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
| 797 | -else $output = str_replace('%gltf2%','false',$output); |
|
| 795 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
| 796 | +if ($gltf2) $output = str_replace('%gltf2%', 'true', $output); |
|
| 797 | +else $output = str_replace('%gltf2%', 'false', $output); |
|
| 798 | 798 | print $output; |
| 799 | 799 | ?> |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | require_once('require/class.Satellite.php'); |
| 6 | 6 | |
| 7 | -$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING); |
|
| 7 | +$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING); |
|
| 8 | 8 | if ($trackident != '') { |
| 9 | 9 | require_once('require/class.SpotterLive.php'); |
| 10 | 10 | $SpotterLive = new SpotterLive(); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident); |
| 15 | 15 | header('Location: '.$globalURL.'/flightid/'.$spotterid); |
| 16 | 16 | } else { |
| 17 | - setcookie('MapTrack',$resulttrackident[0]['flightaware_id']); |
|
| 17 | + setcookie('MapTrack', $resulttrackident[0]['flightaware_id']); |
|
| 18 | 18 | } |
| 19 | 19 | /* |
| 20 | 20 | } else { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | <div class="form-group"> |
| 198 | 198 | <label>From (UTC):</label> |
| 199 | 199 | <div class='input-group date' id='datetimepicker1'> |
| 200 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required /> |
|
| 200 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a", $_COOKIE['archive_begin']); ?>" required /> |
|
| 201 | 201 | <span class="input-group-addon"> |
| 202 | 202 | <span class="glyphicon glyphicon-calendar"></span> |
| 203 | 203 | </span> |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | <div class="form-group"> |
| 207 | 207 | <label>To (UTC):</label> |
| 208 | 208 | <div class='input-group date' id='datetimepicker2'> |
| 209 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" /> |
|
| 209 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a", $_COOKIE['archive_end']); ?>" /> |
|
| 210 | 210 | <span class="input-group-addon"> |
| 211 | 211 | <span class="glyphicon glyphicon-calendar"></span> |
| 212 | 212 | </span> |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | <li><?php echo _("Type of Terrain:"); ?> |
| 351 | 351 | <select class="selectpicker" onchange="terrainType(this);"> |
| 352 | 352 | <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option> |
| 353 | - <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option> |
|
| 354 | - <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option> |
|
| 355 | - <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option> |
|
| 353 | + <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option> |
|
| 354 | + <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option> |
|
| 355 | + <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected'; ?>>ArticDEM</option> |
|
| 356 | 356 | </select> |
| 357 | 357 | </li> |
| 358 | 358 | <?php |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li> |
| 408 | 408 | <?php |
| 409 | 409 | } |
| 410 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
| 410 | + if (time() > mktime(0, 0, 0, 12, 1, date("Y")) && time() < mktime(0, 0, 0, 12, 31, date("Y"))) { |
|
| 411 | 411 | ?> |
| 412 | 412 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
| 413 | 413 | <?php |
@@ -584,10 +584,10 @@ discard block |
||
| 584 | 584 | $Spotter = new Spotter(); |
| 585 | 585 | $allairlinenames = $Spotter->getAllAirlineNames(); |
| 586 | 586 | } |
| 587 | - foreach($allairlinenames as $airline) { |
|
| 587 | + foreach ($allairlinenames as $airline) { |
|
| 588 | 588 | $airline_name = $airline['airline_name']; |
| 589 | - if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...'; |
|
| 590 | - if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) { |
|
| 589 | + if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...'; |
|
| 590 | + if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['filter_Airlines']))) { |
|
| 591 | 591 | echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>'; |
| 592 | 592 | } else { |
| 593 | 593 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
| 607 | 607 | <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
| 608 | 608 | <?php |
| 609 | - foreach($allalliancenames as $alliance) { |
|
| 609 | + foreach ($allalliancenames as $alliance) { |
|
| 610 | 610 | $alliance_name = $alliance['alliance']; |
| 611 | 611 | if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] == $alliance_name) { |
| 612 | 612 | echo '<option value="'.$alliance_name.'" selected>'.$alliance_name.'</option>'; |
@@ -642,8 +642,8 @@ discard block |
||
| 642 | 642 | */ |
| 643 | 643 | $Source = new Source(); |
| 644 | 644 | $datasource = $Source->getLocationInfoByType('gs'); |
| 645 | - foreach($datasource as $src) { |
|
| 646 | - if (isset($_COOKIE['filter_Sources']) && in_array($src['name'],explode(',',$_COOKIE['filter_Sources']))) { |
|
| 645 | + foreach ($datasource as $src) { |
|
| 646 | + if (isset($_COOKIE['filter_Sources']) && in_array($src['name'], explode(',', $_COOKIE['filter_Sources']))) { |
|
| 647 | 647 | echo '<option value="'.$src['name'].'" selected>'.$src['name'].'</option>'; |
| 648 | 648 | } else { |
| 649 | 649 | echo '<option value="'.$src['name'].'">'.$src['name'].'</option>'; |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | else if ($type_name == 'radar') $type_name = 'Radar Calibration'; |
| 732 | 732 | else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches'; |
| 733 | 733 | |
| 734 | - if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) { |
|
| 734 | + if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) { |
|
| 735 | 735 | print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>'; |
| 736 | 736 | } else { |
| 737 | 737 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |