@@ -5,23 +5,23 @@ discard block |
||
| 5 | 5 | $marine = false; |
| 6 | 6 | $usecoord = false; |
| 7 | 7 | if (isset($_GET['tracker'])) { |
| 8 | - $tracker = true; |
|
| 8 | + $tracker = true; |
|
| 9 | 9 | } |
| 10 | 10 | if (isset($_GET['marine'])) { |
| 11 | - $marine = true; |
|
| 11 | + $marine = true; |
|
| 12 | 12 | } |
| 13 | 13 | if ($tracker) { |
| 14 | - require_once('require/class.Tracker.php'); |
|
| 15 | - require_once('require/class.TrackerLive.php'); |
|
| 16 | - require_once('require/class.TrackerArchive.php'); |
|
| 14 | + require_once('require/class.Tracker.php'); |
|
| 15 | + require_once('require/class.TrackerLive.php'); |
|
| 16 | + require_once('require/class.TrackerArchive.php'); |
|
| 17 | 17 | } elseif ($marine) { |
| 18 | - require_once('require/class.Marine.php'); |
|
| 19 | - require_once('require/class.MarineLive.php'); |
|
| 20 | - require_once('require/class.MarineArchive.php'); |
|
| 18 | + require_once('require/class.Marine.php'); |
|
| 19 | + require_once('require/class.MarineLive.php'); |
|
| 20 | + require_once('require/class.MarineArchive.php'); |
|
| 21 | 21 | } else { |
| 22 | - require_once('require/class.Spotter.php'); |
|
| 23 | - require_once('require/class.SpotterLive.php'); |
|
| 24 | - require_once('require/class.SpotterArchive.php'); |
|
| 22 | + require_once('require/class.Spotter.php'); |
|
| 23 | + require_once('require/class.SpotterLive.php'); |
|
| 24 | + require_once('require/class.SpotterArchive.php'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | $Common = new Common(); |
| 42 | 42 | |
| 43 | 43 | if (isset($_GET['download'])) { |
| 44 | - if ($_GET['download'] == "true") |
|
| 45 | - { |
|
| 44 | + if ($_GET['download'] == "true") |
|
| 45 | + { |
|
| 46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | header('Content-Type: text/javascript'); |
| 50 | 50 | |
@@ -497,17 +497,17 @@ discard block |
||
| 497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 498 | 498 | |
| 499 | 499 | if ( |
| 500 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
| 501 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
| 500 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
| 501 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
| 502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 505 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
| 506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
| 507 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
| 508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
| 509 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
| 510 | - ) { |
|
| 504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 505 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
| 506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
| 507 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
| 508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
| 509 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
| 510 | + ) { |
|
| 511 | 511 | if ($tracker) { |
| 512 | 512 | if ($from_archive || $globalArchive) { |
| 513 | 513 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -596,26 +596,26 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 599 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 600 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
| 599 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 600 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
| 601 | 601 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
| 602 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
| 602 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
| 603 | 603 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
| 604 | 604 | if (isset($dairport[0]['latitude'])) { |
| 605 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
| 605 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
| 606 | 606 | } |
| 607 | - } |
|
| 608 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
| 607 | + } |
|
| 608 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
| 609 | 609 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
| 610 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
| 610 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
| 611 | 611 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
| 612 | 612 | if (isset($aairport[0]['latitude'])) { |
| 613 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
| 613 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
| 614 | 614 | } |
| 615 | - } |
|
| 616 | - $output_air .= ']}},'; |
|
| 617 | - $output .= $output_air; |
|
| 618 | - unset($output_air); |
|
| 615 | + } |
|
| 616 | + $output_air .= ']}},'; |
|
| 617 | + $output .= $output_air; |
|
| 618 | + unset($output_air); |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | $output = substr($output, 0, -1); |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | |
| 11 | 11 | class TrackerImport { |
| 12 | - private $all_tracked = array(); |
|
| 13 | - private $last_delete_hourly = 0; |
|
| 14 | - private $last_delete = 0; |
|
| 15 | - private $stats = array(); |
|
| 16 | - private $tmd = 0; |
|
| 17 | - private $source_location = array(); |
|
| 18 | - public $db = null; |
|
| 19 | - public $nb = 0; |
|
| 12 | + private $all_tracked = array(); |
|
| 13 | + private $last_delete_hourly = 0; |
|
| 14 | + private $last_delete = 0; |
|
| 15 | + private $stats = array(); |
|
| 16 | + private $tmd = 0; |
|
| 17 | + private $source_location = array(); |
|
| 18 | + public $db = null; |
|
| 19 | + public $nb = 0; |
|
| 20 | 20 | |
| 21 | - public function __construct($dbc = null) { |
|
| 21 | + public function __construct($dbc = null) { |
|
| 22 | 22 | global $globalBeta; |
| 23 | 23 | $Connection = new Connection($dbc); |
| 24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | */ |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function checkAll() { |
|
| 45 | + public function checkAll() { |
|
| 46 | 46 | global $globalDebug; |
| 47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
| 48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 51 | - $Tracker = new Tracker($this->db); |
|
| 52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 53 | - } |
|
| 51 | + $Tracker = new Tracker($this->db); |
|
| 52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 53 | + } |
|
| 54 | + } |
|
| 54 | 55 | } |
| 55 | - } |
|
| 56 | 56 | |
| 57 | - public function del() { |
|
| 57 | + public function del() { |
|
| 58 | 58 | global $globalDebug; |
| 59 | 59 | // Delete old infos |
| 60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | - if (isset($flight['lastupdate'])) { |
|
| 63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 62 | + if (isset($flight['lastupdate'])) { |
|
| 63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 66 | 66 | /* |
| 67 | 67 | $TrackerLive = new TrackerLive(); |
| 68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
| 69 | 69 | $TrackerLive->db = null; |
| 70 | 70 | */ |
| 71 | - //$real_arrival = $this->arrival($key); |
|
| 72 | - $Tracker = new Tracker($this->db); |
|
| 73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 71 | + //$real_arrival = $this->arrival($key); |
|
| 72 | + $Tracker = new Tracker($this->db); |
|
| 73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 76 | 76 | } |
| 77 | 77 | // Put in archive |
| 78 | 78 | // $Tracker->db = null; |
| 79 | - } |
|
| 80 | - unset($this->all_tracked[$key]); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - } |
|
| 79 | + } |
|
| 80 | + unset($this->all_tracked[$key]); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function add($line) { |
|
| 86 | + public function add($line) { |
|
| 87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // SBS format is CSV format |
| 94 | 94 | if(is_array($line) && isset($line['ident'])) { |
| 95 | - //print_r($line); |
|
| 96 | - if (isset($line['ident'])) { |
|
| 95 | + //print_r($line); |
|
| 96 | + if (isset($line['ident'])) { |
|
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | |
| 111 | 111 | $Common = new Common(); |
| 112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | - else $id = trim($line['id']); |
|
| 112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | + else $id = trim($line['id']); |
|
| 114 | 114 | |
| 115 | 115 | if (!isset($this->all_tracked[$id])) { |
| 116 | - $this->all_tracked[$id] = array(); |
|
| 117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
| 118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
| 119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 120 | - if (!isset($line['id'])) { |
|
| 116 | + $this->all_tracked[$id] = array(); |
|
| 117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
| 118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
| 119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 120 | + if (!isset($line['id'])) { |
|
| 121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 130 | - } else { |
|
| 130 | + } else { |
|
| 131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
| 132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
| 133 | 133 | return ''; |
| 134 | - } |
|
| 134 | + } |
|
| 135 | 135 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
| 137 | 137 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 152 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 152 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
| 153 | 153 | $timeelapsed = microtime(true); |
| 154 | - $Tracker = new Tracker($this->db); |
|
| 155 | - $fromsource = NULL; |
|
| 156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 154 | + $Tracker = new Tracker($this->db); |
|
| 155 | + $fromsource = NULL; |
|
| 156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 158 | 158 | $Tracker->db = null; |
| 159 | 159 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 160 | - } |
|
| 161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 160 | + } |
|
| 161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
| 165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 169 | - if ($distance > 1000 && $distance < 10000) { |
|
| 168 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 169 | + if ($distance > 1000 && $distance < 10000) { |
|
| 170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 171 | 171 | $speed = $speed*3.6; |
| 172 | 172 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | - else unset($timediff); |
|
| 180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 177 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | + else unset($timediff); |
|
| 180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -193,120 +193,120 @@ discard block |
||
| 193 | 193 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 194 | 194 | $this->tmd = 0; |
| 195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 201 | 201 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 202 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 203 | - $dataFound = true; |
|
| 204 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 202 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 203 | + $dataFound = true; |
|
| 204 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 205 | 205 | } |
| 206 | 206 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 207 | 207 | } |
| 208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 211 | 211 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 212 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 213 | - $dataFound = true; |
|
| 214 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 212 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 213 | + $dataFound = true; |
|
| 214 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 215 | 215 | } |
| 216 | 216 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - } else if ($globalDebug && $timediff > 20) { |
|
| 219 | + } else if ($globalDebug && $timediff > 20) { |
|
| 220 | 220 | $this->tmd = $this->tmd + 1; |
| 221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 222 | 222 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 228 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 230 | 230 | } |
| 231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 233 | 233 | } |
| 234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 236 | 236 | } |
| 237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
| 238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
| 239 | - //$dataFound = true; |
|
| 238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
| 239 | + //$dataFound = true; |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 243 | - //$dataFound = true; |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 243 | + //$dataFound = true; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 247 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 248 | 248 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
| 249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
| 250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 251 | 251 | //$dataFound = true; |
| 252 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 252 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
| 260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 263 | - //$dataFound = true; |
|
| 260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 263 | + //$dataFound = true; |
|
| 264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 267 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 269 | 269 | } |
| 270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 271 | 271 | |
| 272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
| 273 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 274 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
| 275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 276 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 273 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 274 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
| 275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 276 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 278 | 278 | $timeelapsed = microtime(true); |
| 279 | 279 | $TrackerLive = new TrackerLive($this->db); |
| 280 | 280 | if (isset($line['id'])) { |
| 281 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 281 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
| 282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 284 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
| 285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 284 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
| 285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 286 | 286 | } else $recent_ident = ''; |
| 287 | 287 | $TrackerLive->db=null; |
| 288 | 288 | |
| 289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 291 | - } else { |
|
| 291 | + } else { |
|
| 292 | 292 | $recent_ident = ''; |
| 293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 294 | - } |
|
| 295 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 296 | - if($recent_ident == "") |
|
| 297 | - { |
|
| 294 | + } |
|
| 295 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 296 | + if($recent_ident == "") |
|
| 297 | + { |
|
| 298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 299 | 299 | //adds the spotter data for the archive |
| 300 | - $highlight = ''; |
|
| 301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 302 | - $timeelapsed = microtime(true); |
|
| 303 | - $Tracker = new Tracker($this->db); |
|
| 304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 305 | - $Tracker->db = null; |
|
| 306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 300 | + $highlight = ''; |
|
| 301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 302 | + $timeelapsed = microtime(true); |
|
| 303 | + $Tracker = new Tracker($this->db); |
|
| 304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 305 | + $Tracker->db = null; |
|
| 306 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 308 | 308 | |
| 309 | - /* |
|
| 309 | + /* |
|
| 310 | 310 | // Add source stat in DB |
| 311 | 311 | $Stats = new Stats($this->db); |
| 312 | 312 | if (!empty($this->stats)) { |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | $Stats->db = null; |
| 335 | 335 | */ |
| 336 | - $this->del(); |
|
| 336 | + $this->del(); |
|
| 337 | 337 | //$ignoreImport = false; |
| 338 | 338 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 339 | 339 | //print_r($this->all_tracked[$id]); |
| 340 | 340 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 342 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 343 | - $TrackerLive = new TrackerLive($this->db); |
|
| 344 | - $TrackerLive->deleteLiveTrackerData(); |
|
| 345 | - $TrackerLive->db=null; |
|
| 346 | - if ($globalDebug) echo " Done\n"; |
|
| 347 | - $this->last_delete = time(); |
|
| 341 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 342 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 343 | + $TrackerLive = new TrackerLive($this->db); |
|
| 344 | + $TrackerLive->deleteLiveTrackerData(); |
|
| 345 | + $TrackerLive->db=null; |
|
| 346 | + if ($globalDebug) echo " Done\n"; |
|
| 347 | + $this->last_delete = time(); |
|
| 348 | 348 | } |
| 349 | - } else { |
|
| 349 | + } else { |
|
| 350 | 350 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | $Tracker->db = null; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - } |
|
| 358 | + } |
|
| 359 | + } |
|
| 359 | 360 | } |
| 360 | - } |
|
| 361 | - //adds the spotter LIVE data |
|
| 362 | - if ($globalDebug) { |
|
| 361 | + //adds the spotter LIVE data |
|
| 362 | + if ($globalDebug) { |
|
| 363 | 363 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 364 | - } |
|
| 365 | - $ignoreImport = false; |
|
| 364 | + } |
|
| 365 | + $ignoreImport = false; |
|
| 366 | 366 | |
| 367 | - if (!$ignoreImport) { |
|
| 367 | + if (!$ignoreImport) { |
|
| 368 | 368 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 370 | 370 | $timeelapsed = microtime(true); |
@@ -436,22 +436,22 @@ discard block |
||
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 440 | - $TrackerLive = new TrackerLive($this->db); |
|
| 441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 442 | - $TrackerLive->db = null; |
|
| 443 | - //TrackerLive->deleteLiveTrackerData(); |
|
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 445 | - $this->last_delete_hourly = time(); |
|
| 439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 440 | + $TrackerLive = new TrackerLive($this->db); |
|
| 441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 442 | + $TrackerLive->db = null; |
|
| 443 | + //TrackerLive->deleteLiveTrackerData(); |
|
| 444 | + if ($globalDebug) echo " Done\n"; |
|
| 445 | + $this->last_delete_hourly = time(); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - } |
|
| 449 | - //$ignoreImport = false; |
|
| 448 | + } |
|
| 449 | + //$ignoreImport = false; |
|
| 450 | 450 | } |
| 451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | 452 | if ($send) return $this->all_tracked[$id]; |
| 453 | - } |
|
| 453 | + } |
|
| 454 | + } |
|
| 454 | 455 | } |
| 455 | - } |
|
| 456 | 456 | } |
| 457 | 457 | ?> |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Gets all the spotter information based on the latest data entry |
|
| 90 | - * |
|
| 91 | - * @return Array the spotter information |
|
| 92 | - * |
|
| 93 | - */ |
|
| 89 | + * Gets all the spotter information based on the latest data entry |
|
| 90 | + * |
|
| 91 | + * @return Array the spotter information |
|
| 92 | + * |
|
| 93 | + */ |
|
| 94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
| 95 | 95 | { |
| 96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Gets Minimal Live Spotter data |
|
| 136 | - * |
|
| 137 | - * @return Array the spotter information |
|
| 138 | - * |
|
| 139 | - */ |
|
| 135 | + * Gets Minimal Live Spotter data |
|
| 136 | + * |
|
| 137 | + * @return Array the spotter information |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | 140 | public function getMinLiveTrackerData($filter = array()) |
| 141 | 141 | { |
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 174 | - * |
|
| 175 | - * @return Array the spotter information |
|
| 176 | - * |
|
| 177 | - */ |
|
| 173 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 174 | + * |
|
| 175 | + * @return Array the spotter information |
|
| 176 | + * |
|
| 177 | + */ |
|
| 178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
| 179 | 179 | { |
| 180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 190 | - } else { |
|
| 190 | + } else { |
|
| 191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
| 193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - try { |
|
| 196 | + try { |
|
| 197 | 197 | $sth = $this->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | - * Gets number of latest data entry |
|
| 209 | - * |
|
| 210 | - * @return String number of entry |
|
| 211 | - * |
|
| 212 | - */ |
|
| 208 | + * Gets number of latest data entry |
|
| 209 | + * |
|
| 210 | + * @return String number of entry |
|
| 211 | + * |
|
| 212 | + */ |
|
| 213 | 213 | public function getLiveTrackerCount($filter = array()) |
| 214 | 214 | { |
| 215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 238 | - * |
|
| 239 | - * @return Array the spotter information |
|
| 240 | - * |
|
| 241 | - */ |
|
| 237 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 238 | + * |
|
| 239 | + * @return Array the spotter information |
|
| 240 | + * |
|
| 241 | + */ |
|
| 242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
| 243 | 243 | { |
| 244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 266 | - * |
|
| 267 | - * @return Array the spotter information |
|
| 268 | - * |
|
| 269 | - */ |
|
| 265 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 266 | + * |
|
| 267 | + * @return Array the spotter information |
|
| 268 | + * |
|
| 269 | + */ |
|
| 270 | 270 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
| 271 | 271 | { |
| 272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 297 | - * |
|
| 298 | - * @return Array the spotter information |
|
| 299 | - * |
|
| 300 | - */ |
|
| 296 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 297 | + * |
|
| 298 | + * @return Array the spotter information |
|
| 299 | + * |
|
| 300 | + */ |
|
| 301 | 301 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
| 302 | 302 | { |
| 303 | 303 | $Tracker = new Tracker($this->db); |
@@ -310,142 +310,142 @@ discard block |
||
| 310 | 310 | if ($lng != '') |
| 311 | 311 | { |
| 312 | 312 | if (!is_numeric($lng)) |
| 313 | - { |
|
| 314 | - return false; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - if ($radius != '') |
|
| 319 | - { |
|
| 320 | - if (!is_numeric($radius)) |
|
| 321 | - { |
|
| 322 | - return false; |
|
| 323 | - } |
|
| 324 | - } |
|
| 313 | + { |
|
| 314 | + return false; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + if ($radius != '') |
|
| 319 | + { |
|
| 320 | + if (!is_numeric($radius)) |
|
| 321 | + { |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | $additional_query = ''; |
| 326 | 326 | if ($interval != '') |
| 327 | - { |
|
| 328 | - if (!is_string($interval)) |
|
| 329 | - { |
|
| 330 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 331 | - return false; |
|
| 332 | - } else { |
|
| 333 | - if ($interval == '1m') |
|
| 334 | - { |
|
| 335 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 336 | - } else if ($interval == '15m'){ |
|
| 337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } else { |
|
| 341 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 327 | + { |
|
| 328 | + if (!is_string($interval)) |
|
| 329 | + { |
|
| 330 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 331 | + return false; |
|
| 332 | + } else { |
|
| 333 | + if ($interval == '1m') |
|
| 334 | + { |
|
| 335 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 336 | + } else if ($interval == '15m'){ |
|
| 337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } else { |
|
| 341 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 345 | 345 | WHERE tracker_live.latitude <> '' |
| 346 | 346 | AND tracker_live.longitude <> '' |
| 347 | 347 | ".$additional_query." |
| 348 | 348 | HAVING distance < :radius |
| 349 | 349 | ORDER BY distance"; |
| 350 | 350 | |
| 351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 352 | 352 | |
| 353 | - return $spotter_array; |
|
| 354 | - } |
|
| 353 | + return $spotter_array; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Gets all the spotter information based on a particular callsign |
|
| 359 | - * |
|
| 360 | - * @return Array the spotter information |
|
| 361 | - * |
|
| 362 | - */ |
|
| 357 | + /** |
|
| 358 | + * Gets all the spotter information based on a particular callsign |
|
| 359 | + * |
|
| 360 | + * @return Array the spotter information |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | 363 | public function getLastLiveTrackerDataByIdent($ident) |
| 364 | 364 | { |
| 365 | 365 | $Tracker = new Tracker($this->db); |
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 370 | 370 | |
| 371 | 371 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 372 | 372 | |
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Gets all the spotter information based on a particular callsign |
|
| 378 | - * |
|
| 379 | - * @return Array the spotter information |
|
| 380 | - * |
|
| 381 | - */ |
|
| 376 | + /** |
|
| 377 | + * Gets all the spotter information based on a particular callsign |
|
| 378 | + * |
|
| 379 | + * @return Array the spotter information |
|
| 380 | + * |
|
| 381 | + */ |
|
| 382 | 382 | public function getDateLiveTrackerDataByIdent($ident,$date) |
| 383 | 383 | { |
| 384 | 384 | $Tracker = new Tracker($this->db); |
| 385 | 385 | date_default_timezone_set('UTC'); |
| 386 | 386 | |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 389 | 389 | |
| 390 | - $date = date('c',$date); |
|
| 390 | + $date = date('c',$date); |
|
| 391 | 391 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 392 | 392 | |
| 393 | 393 | return $spotter_array; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Gets last spotter information based on a particular callsign |
|
| 398 | - * |
|
| 399 | - * @return Array the spotter information |
|
| 400 | - * |
|
| 401 | - */ |
|
| 396 | + /** |
|
| 397 | + * Gets last spotter information based on a particular callsign |
|
| 398 | + * |
|
| 399 | + * @return Array the spotter information |
|
| 400 | + * |
|
| 401 | + */ |
|
| 402 | 402 | public function getLastLiveTrackerDataById($id) |
| 403 | 403 | { |
| 404 | 404 | $Tracker = new Tracker($this->db); |
| 405 | 405 | date_default_timezone_set('UTC'); |
| 406 | 406 | |
| 407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 409 | 409 | |
| 410 | 410 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
| 411 | 411 | |
| 412 | 412 | return $spotter_array; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - /** |
|
| 416 | - * Gets last spotter information based on a particular callsign |
|
| 417 | - * |
|
| 418 | - * @return Array the spotter information |
|
| 419 | - * |
|
| 420 | - */ |
|
| 415 | + /** |
|
| 416 | + * Gets last spotter information based on a particular callsign |
|
| 417 | + * |
|
| 418 | + * @return Array the spotter information |
|
| 419 | + * |
|
| 420 | + */ |
|
| 421 | 421 | public function getDateLiveTrackerDataById($id,$date) |
| 422 | 422 | { |
| 423 | 423 | $Tracker = new Tracker($this->db); |
| 424 | 424 | date_default_timezone_set('UTC'); |
| 425 | 425 | |
| 426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | - $date = date('c',$date); |
|
| 427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 428 | + $date = date('c',$date); |
|
| 429 | 429 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 430 | 430 | |
| 431 | 431 | return $spotter_array; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - /** |
|
| 435 | - * Gets altitude information based on a particular callsign |
|
| 436 | - * |
|
| 437 | - * @return Array the spotter information |
|
| 438 | - * |
|
| 439 | - */ |
|
| 434 | + /** |
|
| 435 | + * Gets altitude information based on a particular callsign |
|
| 436 | + * |
|
| 437 | + * @return Array the spotter information |
|
| 438 | + * |
|
| 439 | + */ |
|
| 440 | 440 | public function getAltitudeLiveTrackerDataByIdent($ident) |
| 441 | 441 | { |
| 442 | 442 | |
| 443 | 443 | date_default_timezone_set('UTC'); |
| 444 | 444 | |
| 445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 447 | 447 | |
| 448 | - try { |
|
| 448 | + try { |
|
| 449 | 449 | |
| 450 | 450 | $sth = $this->db->prepare($query); |
| 451 | 451 | $sth->execute(array(':ident' => $ident)); |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | return $spotter_array; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - /** |
|
| 462 | - * Gets all the spotter information based on a particular id |
|
| 463 | - * |
|
| 464 | - * @return Array the spotter information |
|
| 465 | - * |
|
| 466 | - */ |
|
| 461 | + /** |
|
| 462 | + * Gets all the spotter information based on a particular id |
|
| 463 | + * |
|
| 464 | + * @return Array the spotter information |
|
| 465 | + * |
|
| 466 | + */ |
|
| 467 | 467 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval; |
@@ -491,18 +491,18 @@ discard block |
||
| 491 | 491 | return $spotter_array; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - /** |
|
| 495 | - * Gets all the spotter information based on a particular ident |
|
| 496 | - * |
|
| 497 | - * @return Array the spotter information |
|
| 498 | - * |
|
| 499 | - */ |
|
| 494 | + /** |
|
| 495 | + * Gets all the spotter information based on a particular ident |
|
| 496 | + * |
|
| 497 | + * @return Array the spotter information |
|
| 498 | + * |
|
| 499 | + */ |
|
| 500 | 500 | public function getAllLiveTrackerDataByIdent($ident) |
| 501 | 501 | { |
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 504 | 504 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
| 505 | - try { |
|
| 505 | + try { |
|
| 506 | 506 | |
| 507 | 507 | $sth = $this->db->prepare($query); |
| 508 | 508 | $sth->execute(array(':ident' => $ident)); |
@@ -516,23 +516,23 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Deletes all info in the table |
|
| 520 | - * |
|
| 521 | - * @return String success or false |
|
| 522 | - * |
|
| 523 | - */ |
|
| 519 | + * Deletes all info in the table |
|
| 520 | + * |
|
| 521 | + * @return String success or false |
|
| 522 | + * |
|
| 523 | + */ |
|
| 524 | 524 | public function deleteLiveTrackerData() |
| 525 | 525 | { |
| 526 | 526 | global $globalDBdriver; |
| 527 | 527 | if ($globalDBdriver == 'mysql') { |
| 528 | 528 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
| 529 | 529 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
| 530 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 530 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
| 531 | 531 | } else { |
| 532 | 532 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - try { |
|
| 535 | + try { |
|
| 536 | 536 | |
| 537 | 537 | $sth = $this->db->prepare($query); |
| 538 | 538 | $sth->execute(); |
@@ -544,18 +544,18 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
| 547 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 548 | - * |
|
| 549 | - * @return String success or false |
|
| 550 | - * |
|
| 551 | - */ |
|
| 547 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 548 | + * |
|
| 549 | + * @return String success or false |
|
| 550 | + * |
|
| 551 | + */ |
|
| 552 | 552 | public function deleteLiveTrackerDataNotUpdated() |
| 553 | 553 | { |
| 554 | 554 | global $globalDBdriver, $globalDebug; |
| 555 | 555 | if ($globalDBdriver == 'mysql') { |
| 556 | 556 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
| 557 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 558 | - try { |
|
| 557 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 558 | + try { |
|
| 559 | 559 | |
| 560 | 560 | $sth = $this->db->prepare($query); |
| 561 | 561 | $sth->execute(); |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | return "error"; |
| 564 | 564 | } |
| 565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 566 | - $i = 0; |
|
| 567 | - $j =0; |
|
| 566 | + $i = 0; |
|
| 567 | + $j =0; |
|
| 568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 569 | 569 | foreach($all as $row) |
| 570 | 570 | { |
@@ -572,20 +572,20 @@ discard block |
||
| 572 | 572 | $j++; |
| 573 | 573 | if ($j == 30) { |
| 574 | 574 | if ($globalDebug) echo "."; |
| 575 | - try { |
|
| 575 | + try { |
|
| 576 | 576 | |
| 577 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 578 | 578 | $sth->execute(); |
| 579 | 579 | } catch(PDOException $e) { |
| 580 | 580 | return "error"; |
| 581 | 581 | } |
| 582 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 583 | - $j = 0; |
|
| 582 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
| 583 | + $j = 0; |
|
| 584 | 584 | } |
| 585 | 585 | $query_delete .= "'".$row['famtrackid']."',"; |
| 586 | 586 | } |
| 587 | 587 | if ($i > 0) { |
| 588 | - try { |
|
| 588 | + try { |
|
| 589 | 589 | |
| 590 | 590 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 591 | 591 | $sth->execute(); |
@@ -596,9 +596,9 @@ discard block |
||
| 596 | 596 | return "success"; |
| 597 | 597 | } elseif ($globalDBdriver == 'pgsql') { |
| 598 | 598 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
| 599 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 600 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 601 | - try { |
|
| 599 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 600 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 601 | + try { |
|
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(); |
@@ -642,17 +642,17 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | - * Deletes all info in the table for an ident |
|
| 646 | - * |
|
| 647 | - * @return String success or false |
|
| 648 | - * |
|
| 649 | - */ |
|
| 645 | + * Deletes all info in the table for an ident |
|
| 646 | + * |
|
| 647 | + * @return String success or false |
|
| 648 | + * |
|
| 649 | + */ |
|
| 650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
| 651 | 651 | { |
| 652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 653 | 653 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
| 654 | 654 | |
| 655 | - try { |
|
| 655 | + try { |
|
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(array(':ident' => $ident)); |
@@ -664,17 +664,17 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
| 667 | - * Deletes all info in the table for an id |
|
| 668 | - * |
|
| 669 | - * @return String success or false |
|
| 670 | - * |
|
| 671 | - */ |
|
| 667 | + * Deletes all info in the table for an id |
|
| 668 | + * |
|
| 669 | + * @return String success or false |
|
| 670 | + * |
|
| 671 | + */ |
|
| 672 | 672 | public function deleteLiveTrackerDataById($id) |
| 673 | 673 | { |
| 674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 675 | 675 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
| 676 | 676 | |
| 677 | - try { |
|
| 677 | + try { |
|
| 678 | 678 | |
| 679 | 679 | $sth = $this->db->prepare($query); |
| 680 | 680 | $sth->execute(array(':id' => $id)); |
@@ -687,11 +687,11 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | - * Gets the aircraft ident within the last hour |
|
| 691 | - * |
|
| 692 | - * @return String the ident |
|
| 693 | - * |
|
| 694 | - */ |
|
| 690 | + * Gets the aircraft ident within the last hour |
|
| 691 | + * |
|
| 692 | + * @return String the ident |
|
| 693 | + * |
|
| 694 | + */ |
|
| 695 | 695 | public function getIdentFromLastHour($ident) |
| 696 | 696 | { |
| 697 | 697 | global $globalDBdriver, $globalTimezone; |
@@ -717,14 +717,14 @@ discard block |
||
| 717 | 717 | $ident_result = $row['ident']; |
| 718 | 718 | } |
| 719 | 719 | return $ident_result; |
| 720 | - } |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | 722 | /** |
| 723 | - * Check recent aircraft |
|
| 724 | - * |
|
| 725 | - * @return String the ident |
|
| 726 | - * |
|
| 727 | - */ |
|
| 723 | + * Check recent aircraft |
|
| 724 | + * |
|
| 725 | + * @return String the ident |
|
| 726 | + * |
|
| 727 | + */ |
|
| 728 | 728 | public function checkIdentRecent($ident) |
| 729 | 729 | { |
| 730 | 730 | global $globalDBdriver, $globalTimezone; |
@@ -750,14 +750,14 @@ discard block |
||
| 750 | 750 | $ident_result = $row['famtrackid']; |
| 751 | 751 | } |
| 752 | 752 | return $ident_result; |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | - * Check recent aircraft by id |
|
| 757 | - * |
|
| 758 | - * @return String the ident |
|
| 759 | - * |
|
| 760 | - */ |
|
| 756 | + * Check recent aircraft by id |
|
| 757 | + * |
|
| 758 | + * @return String the ident |
|
| 759 | + * |
|
| 760 | + */ |
|
| 761 | 761 | public function checkIdRecent($id) |
| 762 | 762 | { |
| 763 | 763 | global $globalDBdriver, $globalTimezone; |
@@ -783,19 +783,19 @@ discard block |
||
| 783 | 783 | $ident_result = $row['famtrackid']; |
| 784 | 784 | } |
| 785 | 785 | return $ident_result; |
| 786 | - } |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | 788 | /** |
| 789 | - * Adds a new spotter data |
|
| 790 | - * |
|
| 791 | - * @param String $famtrackid the ID from flightaware |
|
| 792 | - * @param String $ident the flight ident |
|
| 793 | - * @param String $aircraft_icao the aircraft type |
|
| 794 | - * @param String $departure_airport_icao the departure airport |
|
| 795 | - * @param String $arrival_airport_icao the arrival airport |
|
| 796 | - * @return String success or false |
|
| 797 | - * |
|
| 798 | - */ |
|
| 789 | + * Adds a new spotter data |
|
| 790 | + * |
|
| 791 | + * @param String $famtrackid the ID from flightaware |
|
| 792 | + * @param String $ident the flight ident |
|
| 793 | + * @param String $aircraft_icao the aircraft type |
|
| 794 | + * @param String $departure_airport_icao the departure airport |
|
| 795 | + * @param String $arrival_airport_icao the arrival airport |
|
| 796 | + * @return String success or false |
|
| 797 | + * |
|
| 798 | + */ |
|
| 799 | 799 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 800 | 800 | { |
| 801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 869 | 869 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 870 | 870 | |
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 873 | 873 | |
| 874 | 874 | $query = ''; |
| 875 | 875 | if ($globalArchive) { |
@@ -884,16 +884,16 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | $sth = $this->db->prepare($query); |
| 886 | 886 | $sth->execute($query_values); |
| 887 | - } catch(PDOException $e) { |
|
| 888 | - return "error : ".$e->getMessage(); |
|
| 889 | - } |
|
| 890 | - echo 'putinarchive : '.$putinarchive."\n"; |
|
| 891 | - echo 'noarchive : '.$noarchive."\n"; |
|
| 887 | + } catch(PDOException $e) { |
|
| 888 | + return "error : ".$e->getMessage(); |
|
| 889 | + } |
|
| 890 | + echo 'putinarchive : '.$putinarchive."\n"; |
|
| 891 | + echo 'noarchive : '.$noarchive."\n"; |
|
| 892 | 892 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 893 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 894 | - $TrackerArchive = new TrackerArchive($this->db); |
|
| 895 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 896 | - if ($globalDebug) echo $result.')'; |
|
| 893 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 894 | + $TrackerArchive = new TrackerArchive($this->db); |
|
| 895 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 896 | + if ($globalDebug) echo $result.')'; |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | return "success"; |