@@ -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 | ?> |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 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 | 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']); |
|
| 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 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | 62 | if (isset($flight['lastupdate'])) { |
| 63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
| 65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
| 66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | //$real_arrival = $this->arrival($key); |
| 72 | 72 | $Tracker = new Tracker($this->db); |
| 73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 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']); |
|
| 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 |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $send = false; |
| 92 | 92 | |
| 93 | 93 | // SBS format is CSV format |
| 94 | - if(is_array($line) && isset($line['ident'])) { |
|
| 94 | + if (is_array($line) && isset($line['ident'])) { |
|
| 95 | 95 | //print_r($line); |
| 96 | 96 | if (isset($line['ident'])) { |
| 97 | 97 | |
@@ -114,33 +114,33 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (!isset($this->all_tracked[$id])) { |
| 116 | 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())); |
|
| 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 | 120 | if (!isset($line['id'])) { |
| 121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 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'])); |
|
| 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 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 127 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 128 | 128 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 130 | 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 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 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 ''; |
| 138 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 138 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 139 | 139 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
| 140 | 140 | return ''; |
| 141 | 141 | } elseif (!isset($line['datetime'])) { |
| 142 | 142 | date_default_timezone_set('UTC'); |
| 143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 144 | 144 | } else { |
| 145 | 145 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
| 146 | 146 | 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']))); |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 152 | 152 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
| 153 | 153 | $timeelapsed = microtime(true); |
| 154 | 154 | $Tracker = new Tracker($this->db); |
| 155 | 155 | $fromsource = NULL; |
| 156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 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 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 159 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 160 | 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'])); |
|
| 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'); |
|
| 168 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 169 | 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 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 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 | 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']); |
|
| 178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 179 | 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')))) { |
|
| 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; |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 188 | 188 | $timeelapsed = microtime(true); |
| 189 | 189 | $Tracker = new Tracker($this->db); |
| 190 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 190 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 191 | 191 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 192 | 192 | $Tracker->db = null; |
| 193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 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 | } |
@@ -198,73 +198,73 @@ discard block |
||
| 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 | - 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') { |
|
| 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 | 202 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 203 | 203 | $dataFound = true; |
| 204 | 204 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 205 | 205 | } |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 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 | 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 | - 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') { |
|
| 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 | 212 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 213 | 213 | $dataFound = true; |
| 214 | 214 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 215 | 215 | } |
| 216 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 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 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 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 - "; |
|
| 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 | + 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 | 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'])); |
|
| 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'])); |
|
| 238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
| 239 | 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'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 243 | 243 | //$dataFound = true; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | 247 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 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 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
|
| 250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
| 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 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100))); |
|
| 250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
| 251 | 251 | //$dataFound = true; |
| 252 | 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)); |
|
| 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 | 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; |
|
| 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 | 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; |
@@ -272,39 +272,39 @@ discard block |
||
| 272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
| 273 | 273 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 274 | 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'])) { |
|
| 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 | 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 | 281 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 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 | 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"; |
|
| 285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 286 | 286 | } else $recent_ident = ''; |
| 287 | - $TrackerLive->db=null; |
|
| 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 | 291 | } else { |
| 292 | 292 | $recent_ident = ''; |
| 293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 294 | 294 | } |
| 295 | 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 == "") |
|
| 296 | + if ($recent_ident == "") |
|
| 297 | 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 | 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'))); |
|
| 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 | 302 | $timeelapsed = microtime(true); |
| 303 | 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']); |
|
| 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 | 305 | $Tracker->db = null; |
| 306 | 306 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\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 |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 343 | 343 | $TrackerLive = new TrackerLive($this->db); |
| 344 | 344 | $TrackerLive->deleteLiveTrackerData(); |
| 345 | - $TrackerLive->db=null; |
|
| 345 | + $TrackerLive->db = null; |
|
| 346 | 346 | if ($globalDebug) echo " Done\n"; |
| 347 | 347 | $this->last_delete = time(); |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
| 353 | 353 | $Tracker = new Tracker($this->db); |
| 354 | - $Tracker->updateLatestTrackerData($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]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 354 | + $Tracker->updateLatestTrackerData($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]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 355 | 355 | $Tracker->db = null; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -365,14 +365,14 @@ discard block |
||
| 365 | 365 | $ignoreImport = false; |
| 366 | 366 | |
| 367 | 367 | if (!$ignoreImport) { |
| 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'])) { |
|
| 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); |
| 371 | 371 | $TrackerLive = new TrackerLive($this->db); |
| 372 | - $result = $TrackerLive->addLiveTrackerData($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]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 372 | + $result = $TrackerLive->addLiveTrackerData($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]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 373 | 373 | $TrackerLive->db = null; |
| 374 | 374 | $this->all_tracked[$id]['putinarchive'] = false; |
| 375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 376 | 376 | |
| 377 | 377 | // Put statistics in $this->stats variable |
| 378 | 378 | /* |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 433 | 433 | if ($globalDebug) echo $result."\n"; |
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 434 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 435 | 435 | //$this->del(); |
| 436 | 436 | |
| 437 | 437 | |
@@ -44,7 +44,9 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function checkAll() { |
| 46 | 46 | global $globalDebug; |
| 47 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 47 | + if ($globalDebug) { |
|
| 48 | + echo "Update last seen tracked data...\n"; |
|
| 49 | + } |
|
| 48 | 50 | foreach ($this->all_tracked as $key => $flight) { |
| 49 | 51 | if (isset($this->all_tracked[$key]['id'])) { |
| 50 | 52 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -57,12 +59,16 @@ discard block |
||
| 57 | 59 | public function del() { |
| 58 | 60 | global $globalDebug; |
| 59 | 61 | // Delete old infos |
| 60 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + if ($globalDebug) { |
|
| 63 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 64 | + } |
|
| 61 | 65 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | 66 | if (isset($flight['lastupdate'])) { |
| 63 | 67 | if ($flight['lastupdate'] < (time()-3000)) { |
| 64 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
| 65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + if ($globalDebug) { |
|
| 70 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 71 | + } |
|
| 66 | 72 | /* |
| 67 | 73 | $TrackerLive = new TrackerLive(); |
| 68 | 74 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -72,7 +78,9 @@ discard block |
||
| 72 | 78 | $Tracker = new Tracker($this->db); |
| 73 | 79 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 74 | 80 | $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 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + if ($globalDebug && $result != 'success') { |
|
| 82 | + echo '!!! ERROR : '.$result."\n"; |
|
| 83 | + } |
|
| 76 | 84 | } |
| 77 | 85 | // Put in archive |
| 78 | 86 | // $Tracker->db = null; |
@@ -85,7 +93,9 @@ discard block |
||
| 85 | 93 | |
| 86 | 94 | public function add($line) { |
| 87 | 95 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 88 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 96 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 97 | + $globalCoordMinChange = '0.02'; |
|
| 98 | + } |
|
| 89 | 99 | date_default_timezone_set('UTC'); |
| 90 | 100 | $dataFound = false; |
| 91 | 101 | $send = false; |
@@ -109,8 +119,11 @@ discard block |
||
| 109 | 119 | */ |
| 110 | 120 | |
| 111 | 121 | $Common = new Common(); |
| 112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | - else $id = trim($line['id']); |
|
| 122 | + if (!isset($line['id'])) { |
|
| 123 | + $id = trim($line['ident']); |
|
| 124 | + } else { |
|
| 125 | + $id = trim($line['id']); |
|
| 126 | + } |
|
| 114 | 127 | |
| 115 | 128 | if (!isset($this->all_tracked[$id])) { |
| 116 | 129 | $this->all_tracked[$id] = array(); |
@@ -118,31 +131,46 @@ discard block |
||
| 118 | 131 | $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 | 132 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 120 | 133 | if (!isset($line['id'])) { |
| 121 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 134 | + if (!isset($globalDaemon)) { |
|
| 135 | + $globalDaemon = TRUE; |
|
| 136 | + } |
|
| 122 | 137 | $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; |
|
| 138 | + } else { |
|
| 139 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 140 | + } |
|
| 141 | + if ($globalAllTracked !== FALSE) { |
|
| 142 | + $dataFound = true; |
|
| 143 | + } |
|
| 125 | 144 | } |
| 126 | 145 | |
| 127 | 146 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 128 | 147 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 129 | 148 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 130 | 149 | } else { |
| 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 | - 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"; |
|
| 150 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 151 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 152 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 153 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 154 | + } |
|
| 133 | 155 | return ''; |
| 134 | 156 | } |
| 135 | 157 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 136 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 158 | + if ($globalDebug) { |
|
| 159 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 160 | + } |
|
| 137 | 161 | return ''; |
| 138 | 162 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 139 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 163 | + if ($globalDebug) { |
|
| 164 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 165 | + } |
|
| 140 | 166 | return ''; |
| 141 | 167 | } elseif (!isset($line['datetime'])) { |
| 142 | 168 | date_default_timezone_set('UTC'); |
| 143 | 169 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 144 | 170 | } else { |
| 145 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 171 | + if ($globalDebug) { |
|
| 172 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
| 173 | + } |
|
| 146 | 174 | return ''; |
| 147 | 175 | } |
| 148 | 176 | |
@@ -154,11 +182,17 @@ discard block |
||
| 154 | 182 | $Tracker = new Tracker($this->db); |
| 155 | 183 | $fromsource = NULL; |
| 156 | 184 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 157 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 185 | + if ($globalDebug && $result != 'success') { |
|
| 186 | + echo '!!! ERROR : '.$result."\n"; |
|
| 187 | + } |
|
| 158 | 188 | $Tracker->db = null; |
| 159 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 189 | + if ($globalDebugTimeElapsed) { |
|
| 190 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 194 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 160 | 195 | } |
| 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 | 196 | } |
| 163 | 197 | |
| 164 | 198 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -169,14 +203,21 @@ discard block |
||
| 169 | 203 | if ($distance > 1000 && $distance < 10000) { |
| 170 | 204 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 171 | 205 | $speed = $speed*3.6; |
| 172 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 173 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 206 | + if ($speed < 1000) { |
|
| 207 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 208 | + } |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 211 | + } |
|
| 174 | 212 | } |
| 175 | 213 | } |
| 176 | 214 | |
| 177 | 215 | 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); |
|
| 216 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 217 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 218 | + } else { |
|
| 219 | + unset($timediff); |
|
| 220 | + } |
|
| 180 | 221 | 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 | 222 | 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 | 223 | 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'])) { |
@@ -184,20 +225,30 @@ discard block |
||
| 184 | 225 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 185 | 226 | $this->all_tracked[$id]['putinarchive'] = true; |
| 186 | 227 | |
| 187 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 230 | + } |
|
| 188 | 231 | $timeelapsed = microtime(true); |
| 189 | 232 | $Tracker = new Tracker($this->db); |
| 190 | 233 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 191 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 234 | + if (!empty($all_country)) { |
|
| 235 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 236 | + } |
|
| 192 | 237 | $Tracker->db = null; |
| 193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 238 | + if ($globalDebugTimeElapsed) { |
|
| 239 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 240 | + } |
|
| 194 | 241 | $this->tmd = 0; |
| 195 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 244 | + } |
|
| 196 | 245 | } |
| 197 | 246 | } |
| 198 | 247 | |
| 199 | 248 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 200 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 249 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 250 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 251 | + } |
|
| 201 | 252 | 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 | 253 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 203 | 254 | $dataFound = true; |
@@ -206,8 +257,12 @@ discard block |
||
| 206 | 257 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 207 | 258 | } |
| 208 | 259 | 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; |
|
| 210 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 260 | + if ($line['longitude'] > 180) { |
|
| 261 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 262 | + } |
|
| 263 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 264 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 265 | + } |
|
| 211 | 266 | 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 | 267 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 213 | 268 | $dataFound = true; |
@@ -225,7 +280,9 @@ discard block |
||
| 225 | 280 | } |
| 226 | 281 | } |
| 227 | 282 | 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; |
|
| 283 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 284 | + $dataFound = true; |
|
| 285 | + } |
|
| 229 | 286 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 230 | 287 | } |
| 231 | 288 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -245,7 +302,9 @@ discard block |
||
| 245 | 302 | |
| 246 | 303 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | 304 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 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; |
|
| 305 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 306 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 307 | + } |
|
| 249 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
| 250 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 251 | 310 | //$dataFound = true; |
@@ -257,15 +316,21 @@ discard block |
||
| 257 | 316 | } |
| 258 | 317 | |
| 259 | 318 | 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; |
|
| 319 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 320 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 321 | + } |
|
| 261 | 322 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 262 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 263 | 324 | //$dataFound = true; |
| 264 | 325 | } 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 | 326 | $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 | 327 | $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"; |
|
| 328 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 329 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 330 | + } |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 333 | + } |
|
| 269 | 334 | } |
| 270 | 335 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 271 | 336 | |
@@ -274,20 +339,31 @@ discard block |
||
| 274 | 339 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 275 | 340 | 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 | 341 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 277 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "Check if aircraft is already in DB..."; |
|
| 344 | + } |
|
| 278 | 345 | $timeelapsed = microtime(true); |
| 279 | 346 | $TrackerLive = new TrackerLive($this->db); |
| 280 | 347 | if (isset($line['id'])) { |
| 281 | 348 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 349 | + if ($globalDebugTimeElapsed) { |
|
| 350 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 351 | + } |
|
| 283 | 352 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 284 | 353 | $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 | - } else $recent_ident = ''; |
|
| 354 | + if ($globalDebugTimeElapsed) { |
|
| 355 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | + $recent_ident = ''; |
|
| 359 | + } |
|
| 287 | 360 | $TrackerLive->db=null; |
| 288 | 361 | |
| 289 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 290 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 362 | + if ($globalDebug && $recent_ident == '') { |
|
| 363 | + echo " Not in DB.\n"; |
|
| 364 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 365 | + echo " Already in DB.\n"; |
|
| 366 | + } |
|
| 291 | 367 | } else { |
| 292 | 368 | $recent_ident = ''; |
| 293 | 369 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -295,16 +371,24 @@ discard block |
||
| 295 | 371 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 296 | 372 | if($recent_ident == "") |
| 297 | 373 | { |
| 298 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 374 | + if ($globalDebug) { |
|
| 375 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 376 | + } |
|
| 299 | 377 | //adds the spotter data for the archive |
| 300 | 378 | $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'))); |
|
| 379 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 380 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 381 | + } |
|
| 302 | 382 | $timeelapsed = microtime(true); |
| 303 | 383 | $Tracker = new Tracker($this->db); |
| 304 | 384 | $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 | 385 | $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"; |
|
| 386 | + if ($globalDebug && isset($result)) { |
|
| 387 | + echo $result."\n"; |
|
| 388 | + } |
|
| 389 | + if ($globalDebugTimeElapsed) { |
|
| 390 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 391 | + } |
|
| 308 | 392 | |
| 309 | 393 | /* |
| 310 | 394 | // Add source stat in DB |
@@ -338,12 +422,16 @@ discard block |
||
| 338 | 422 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 339 | 423 | //print_r($this->all_tracked[$id]); |
| 340 | 424 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 425 | + if ($globalDebug) { |
|
| 426 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 427 | + } |
|
| 342 | 428 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 343 | 429 | $TrackerLive = new TrackerLive($this->db); |
| 344 | 430 | $TrackerLive->deleteLiveTrackerData(); |
| 345 | 431 | $TrackerLive->db=null; |
| 346 | - if ($globalDebug) echo " Done\n"; |
|
| 432 | + if ($globalDebug) { |
|
| 433 | + echo " Done\n"; |
|
| 434 | + } |
|
| 347 | 435 | $this->last_delete = time(); |
| 348 | 436 | } |
| 349 | 437 | } else { |
@@ -366,13 +454,17 @@ discard block |
||
| 366 | 454 | |
| 367 | 455 | if (!$ignoreImport) { |
| 368 | 456 | 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 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 457 | + if ($globalDebug) { |
|
| 458 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 459 | + } |
|
| 370 | 460 | $timeelapsed = microtime(true); |
| 371 | 461 | $TrackerLive = new TrackerLive($this->db); |
| 372 | 462 | $result = $TrackerLive->addLiveTrackerData($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]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 373 | 463 | $TrackerLive->db = null; |
| 374 | 464 | $this->all_tracked[$id]['putinarchive'] = false; |
| 375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 465 | + if ($globalDebugTimeElapsed) { |
|
| 466 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 467 | + } |
|
| 376 | 468 | |
| 377 | 469 | // Put statistics in $this->stats variable |
| 378 | 470 | /* |
@@ -429,19 +521,29 @@ discard block |
||
| 429 | 521 | */ |
| 430 | 522 | |
| 431 | 523 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 524 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 525 | + $send = true; |
|
| 526 | + } |
|
| 527 | + if ($globalDebug) { |
|
| 528 | + echo $result."\n"; |
|
| 529 | + } |
|
| 530 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 531 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 532 | + } |
|
| 435 | 533 | //$this->del(); |
| 436 | 534 | |
| 437 | 535 | |
| 438 | 536 | 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..."; |
|
| 537 | + if ($globalDebug) { |
|
| 538 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 539 | + } |
|
| 440 | 540 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 541 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 542 | $TrackerLive->db = null; |
| 443 | 543 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 544 | + if ($globalDebug) { |
|
| 545 | + echo " Done\n"; |
|
| 546 | + } |
|
| 445 | 547 | $this->last_delete_hourly = time(); |
| 446 | 548 | } |
| 447 | 549 | |
@@ -449,7 +551,9 @@ discard block |
||
| 449 | 551 | //$ignoreImport = false; |
| 450 | 552 | } |
| 451 | 553 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 554 | + if ($send) { |
|
| 555 | + return $this->all_tracked[$id]; |
|
| 556 | + } |
|
| 453 | 557 | } |
| 454 | 558 | } |
| 455 | 559 | } |
@@ -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"; |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
| 128 | 128 | } |
| 129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 130 | 130 | |
| 131 | 131 | return $spotter_array; |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
| 143 | 143 | date_default_timezone_set('UTC'); |
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 145 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | try { |
| 161 | 161 | $sth = $this->db->prepare($query); |
| 162 | 162 | $sth->execute(); |
| 163 | - } catch(PDOException $e) { |
|
| 163 | + } catch (PDOException $e) { |
|
| 164 | 164 | echo $e->getMessage(); |
| 165 | 165 | die; |
| 166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | global $globalDBdriver, $globalLiveInterval; |
| 181 | 181 | date_default_timezone_set('UTC'); |
| 182 | 182 | |
| 183 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 183 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 184 | 184 | |
| 185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 186 | 186 | if ($globalDBdriver == 'mysql') { |
| 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 |
|
| 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 | 190 | } else { |
| 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 |
|
| 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 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | try { |
| 197 | 197 | $sth = $this->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | - } catch(PDOException $e) { |
|
| 199 | + } catch (PDOException $e) { |
|
| 200 | 200 | echo $e->getMessage(); |
| 201 | 201 | die; |
| 202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | public function getLiveTrackerCount($filter = array()) |
| 214 | 214 | { |
| 215 | 215 | global $globalDBdriver, $globalLiveInterval; |
| 216 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 216 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 217 | 217 | |
| 218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | try { |
| 225 | 225 | $sth = $this->db->prepare($query); |
| 226 | 226 | $sth->execute(); |
| 227 | - } catch(PDOException $e) { |
|
| 227 | + } catch (PDOException $e) { |
|
| 228 | 228 | echo $e->getMessage(); |
| 229 | 229 | die; |
| 230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | $filter_query = $this->getFilter($filter); |
| 248 | 248 | |
| 249 | 249 | if (is_array($coord)) { |
| 250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 254 | 254 | } else return array(); |
| 255 | 255 | if ($globalDBdriver == 'mysql') { |
| 256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -275,17 +275,17 @@ discard block |
||
| 275 | 275 | $filter_query = $this->getFilter($filter); |
| 276 | 276 | |
| 277 | 277 | if (is_array($coord)) { |
| 278 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 280 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 281 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 280 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 281 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 282 | 282 | } else return array(); |
| 283 | 283 | if ($globalDBdriver == 'mysql') { |
| 284 | 284 | $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 |
| 285 | 285 | 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' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 286 | 286 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
| 287 | 287 | } else { |
| 288 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 288 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 289 | 289 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
| 290 | 290 | } |
| 291 | 291 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | if ($interval == '1m') |
| 334 | 334 | { |
| 335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 336 | - } else if ($interval == '15m'){ |
|
| 336 | + } else if ($interval == '15m') { |
|
| 337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 342 | 342 | } |
| 343 | 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 |
|
| 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 | 353 | return $spotter_array; |
| 354 | 354 | } |
@@ -366,9 +366,9 @@ discard block |
||
| 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 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 371 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 372 | 372 | |
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
@@ -379,16 +379,16 @@ discard block |
||
| 379 | 379 | * @return Array the spotter information |
| 380 | 380 | * |
| 381 | 381 | */ |
| 382 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
| 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); |
|
| 391 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 390 | + $date = date('c', $date); |
|
| 391 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 392 | 392 | |
| 393 | 393 | return $spotter_array; |
| 394 | 394 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 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 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 410 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 411 | 411 | |
| 412 | 412 | return $spotter_array; |
| 413 | 413 | } |
@@ -418,15 +418,15 @@ discard block |
||
| 418 | 418 | * @return Array the spotter information |
| 419 | 419 | * |
| 420 | 420 | */ |
| 421 | - public function getDateLiveTrackerDataById($id,$date) |
|
| 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); |
|
| 429 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 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 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 430 | 430 | |
| 431 | 431 | return $spotter_array; |
| 432 | 432 | } |
@@ -443,13 +443,13 @@ discard block |
||
| 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 | 448 | try { |
| 449 | 449 | |
| 450 | 450 | $sth = $this->db->prepare($query); |
| 451 | 451 | $sth->execute(array(':ident' => $ident)); |
| 452 | - } catch(PDOException $e) { |
|
| 452 | + } catch (PDOException $e) { |
|
| 453 | 453 | echo $e->getMessage(); |
| 454 | 454 | die; |
| 455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return Array the spotter information |
| 465 | 465 | * |
| 466 | 466 | */ |
| 467 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
| 467 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval; |
| 470 | 470 | date_default_timezone_set('UTC'); |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | try { |
| 484 | 484 | $sth = $this->db->prepare($query); |
| 485 | 485 | $sth->execute(array(':id' => $id)); |
| 486 | - } catch(PDOException $e) { |
|
| 486 | + } catch (PDOException $e) { |
|
| 487 | 487 | echo $e->getMessage(); |
| 488 | 488 | die; |
| 489 | 489 | } |
@@ -501,12 +501,12 @@ discard block |
||
| 501 | 501 | { |
| 502 | 502 | date_default_timezone_set('UTC'); |
| 503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 504 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 504 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 505 | 505 | try { |
| 506 | 506 | |
| 507 | 507 | $sth = $this->db->prepare($query); |
| 508 | 508 | $sth->execute(array(':ident' => $ident)); |
| 509 | - } catch(PDOException $e) { |
|
| 509 | + } catch (PDOException $e) { |
|
| 510 | 510 | echo $e->getMessage(); |
| 511 | 511 | die; |
| 512 | 512 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | $sth = $this->db->prepare($query); |
| 538 | 538 | $sth->execute(); |
| 539 | - } catch(PDOException $e) { |
|
| 539 | + } catch (PDOException $e) { |
|
| 540 | 540 | return "error"; |
| 541 | 541 | } |
| 542 | 542 | |
@@ -559,14 +559,14 @@ discard block |
||
| 559 | 559 | |
| 560 | 560 | $sth = $this->db->prepare($query); |
| 561 | 561 | $sth->execute(); |
| 562 | - } catch(PDOException $e) { |
|
| 562 | + } catch (PDOException $e) { |
|
| 563 | 563 | return "error"; |
| 564 | 564 | } |
| 565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 566 | 566 | $i = 0; |
| 567 | - $j =0; |
|
| 567 | + $j = 0; |
|
| 568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 569 | - foreach($all as $row) |
|
| 569 | + foreach ($all as $row) |
|
| 570 | 570 | { |
| 571 | 571 | $i++; |
| 572 | 572 | $j++; |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | if ($globalDebug) echo "."; |
| 575 | 575 | try { |
| 576 | 576 | |
| 577 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 577 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 578 | 578 | $sth->execute(); |
| 579 | - } catch(PDOException $e) { |
|
| 579 | + } catch (PDOException $e) { |
|
| 580 | 580 | return "error"; |
| 581 | 581 | } |
| 582 | 582 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -587,9 +587,9 @@ discard block |
||
| 587 | 587 | if ($i > 0) { |
| 588 | 588 | try { |
| 589 | 589 | |
| 590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 591 | 591 | $sth->execute(); |
| 592 | - } catch(PDOException $e) { |
|
| 592 | + } catch (PDOException $e) { |
|
| 593 | 593 | return "error"; |
| 594 | 594 | } |
| 595 | 595 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | $sth = $this->db->prepare($query); |
| 604 | 604 | $sth->execute(); |
| 605 | - } catch(PDOException $e) { |
|
| 605 | + } catch (PDOException $e) { |
|
| 606 | 606 | return "error"; |
| 607 | 607 | } |
| 608 | 608 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -650,13 +650,13 @@ discard block |
||
| 650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
| 651 | 651 | { |
| 652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 653 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 653 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 654 | 654 | |
| 655 | 655 | try { |
| 656 | 656 | |
| 657 | 657 | $sth = $this->db->prepare($query); |
| 658 | 658 | $sth->execute(array(':ident' => $ident)); |
| 659 | - } catch(PDOException $e) { |
|
| 659 | + } catch (PDOException $e) { |
|
| 660 | 660 | return "error"; |
| 661 | 661 | } |
| 662 | 662 | |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | public function deleteLiveTrackerDataById($id) |
| 673 | 673 | { |
| 674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 675 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 675 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 676 | 676 | |
| 677 | 677 | try { |
| 678 | 678 | |
| 679 | 679 | $sth = $this->db->prepare($query); |
| 680 | 680 | $sth->execute(array(':id' => $id)); |
| 681 | - } catch(PDOException $e) { |
|
| 681 | + } catch (PDOException $e) { |
|
| 682 | 682 | return "error"; |
| 683 | 683 | } |
| 684 | 684 | |
@@ -696,13 +696,13 @@ discard block |
||
| 696 | 696 | { |
| 697 | 697 | global $globalDBdriver, $globalTimezone; |
| 698 | 698 | if ($globalDBdriver == 'mysql') { |
| 699 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 699 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 700 | 700 | WHERE tracker_live.ident = :ident |
| 701 | 701 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 702 | 702 | AND tracker_live.date < UTC_TIMESTAMP()'; |
| 703 | 703 | $query_data = array(':ident' => $ident); |
| 704 | 704 | } else { |
| 705 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 705 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 706 | 706 | WHERE tracker_live.ident = :ident |
| 707 | 707 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 708 | 708 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -711,8 +711,8 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | $sth = $this->db->prepare($query); |
| 713 | 713 | $sth->execute($query_data); |
| 714 | - $ident_result=''; |
|
| 715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 714 | + $ident_result = ''; |
|
| 715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 716 | 716 | { |
| 717 | 717 | $ident_result = $row['ident']; |
| 718 | 718 | } |
@@ -729,13 +729,13 @@ discard block |
||
| 729 | 729 | { |
| 730 | 730 | global $globalDBdriver, $globalTimezone; |
| 731 | 731 | if ($globalDBdriver == 'mysql') { |
| 732 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 732 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 733 | 733 | WHERE tracker_live.ident = :ident |
| 734 | 734 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 735 | 735 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 736 | 736 | $query_data = array(':ident' => $ident); |
| 737 | 737 | } else { |
| 738 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 738 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 739 | 739 | WHERE tracker_live.ident = :ident |
| 740 | 740 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 741 | 741 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -744,8 +744,8 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | $sth = $this->db->prepare($query); |
| 746 | 746 | $sth->execute($query_data); |
| 747 | - $ident_result=''; |
|
| 748 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 747 | + $ident_result = ''; |
|
| 748 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 749 | 749 | { |
| 750 | 750 | $ident_result = $row['famtrackid']; |
| 751 | 751 | } |
@@ -762,13 +762,13 @@ discard block |
||
| 762 | 762 | { |
| 763 | 763 | global $globalDBdriver, $globalTimezone; |
| 764 | 764 | if ($globalDBdriver == 'mysql') { |
| 765 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 765 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 766 | 766 | WHERE tracker_live.famtrackid = :id |
| 767 | 767 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 768 | 768 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 769 | 769 | $query_data = array(':id' => $id); |
| 770 | 770 | } else { |
| 771 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 771 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 772 | 772 | WHERE tracker_live.famtrackid = :id |
| 773 | 773 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 774 | 774 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | $sth = $this->db->prepare($query); |
| 779 | 779 | $sth->execute($query_data); |
| 780 | - $ident_result=''; |
|
| 781 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 780 | + $ident_result = ''; |
|
| 781 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 782 | 782 | { |
| 783 | 783 | $ident_result = $row['famtrackid']; |
| 784 | 784 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @return String success or false |
| 797 | 797 | * |
| 798 | 798 | */ |
| 799 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 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; |
| 802 | 802 | $Common = new Common(); |
@@ -855,21 +855,21 @@ discard block |
||
| 855 | 855 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 856 | 856 | |
| 857 | 857 | |
| 858 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 859 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 860 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 863 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 865 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 866 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 867 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 868 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 869 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 870 | - |
|
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 858 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 859 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 860 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 863 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 865 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 866 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 867 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 868 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 869 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 870 | + |
|
| 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) { |
@@ -879,12 +879,12 @@ discard block |
||
| 879 | 879 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 880 | 880 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 881 | 881 | |
| 882 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 882 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 883 | 883 | try { |
| 884 | 884 | |
| 885 | 885 | $sth = $this->db->prepare($query); |
| 886 | 886 | $sth->execute($query_values); |
| 887 | - } catch(PDOException $e) { |
|
| 887 | + } catch (PDOException $e) { |
|
| 888 | 888 | return "error : ".$e->getMessage(); |
| 889 | 889 | } |
| 890 | 890 | echo 'putinarchive : '.$putinarchive."\n"; |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 893 | 893 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 894 | 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); |
|
| 895 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
| 896 | 896 | if ($globalDebug) echo $result.')'; |
| 897 | 897 | } |
| 898 | 898 | |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | |
| 903 | 903 | public function getOrderBy() |
| 904 | 904 | { |
| 905 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 905 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 906 | 906 | return $orderby; |
| 907 | 907 | } |
| 908 | 908 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 127 | + if (!isset($globalLiveInterval)) { |
|
| 128 | + $globalLiveInterval = '200'; |
|
| 129 | + } |
|
| 123 | 130 | if ($globalDBdriver == 'mysql') { |
| 124 | 131 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 125 | 132 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 148 | 157 | if ($globalDBdriver == 'mysql') { |
| 149 | 158 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 150 | 159 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -182,7 +191,9 @@ discard block |
||
| 182 | 191 | |
| 183 | 192 | $filter_query = $this->getFilter($filter,true,true); |
| 184 | 193 | |
| 185 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 194 | + if (!isset($globalLiveInterval)) { |
|
| 195 | + $globalLiveInterval = '200'; |
|
| 196 | + } |
|
| 186 | 197 | if ($globalDBdriver == 'mysql') { |
| 187 | 198 | $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 | 199 | 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' |
@@ -215,7 +226,9 @@ discard block |
||
| 215 | 226 | global $globalDBdriver, $globalLiveInterval; |
| 216 | 227 | $filter_query = $this->getFilter($filter,true,true); |
| 217 | 228 | |
| 218 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 229 | + if (!isset($globalLiveInterval)) { |
|
| 230 | + $globalLiveInterval = '200'; |
|
| 231 | + } |
|
| 219 | 232 | if ($globalDBdriver == 'mysql') { |
| 220 | 233 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 221 | 234 | } else { |
@@ -243,7 +256,9 @@ discard block |
||
| 243 | 256 | { |
| 244 | 257 | global $globalDBdriver, $globalLiveInterval; |
| 245 | 258 | $Spotter = new Spotter($this->db); |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 259 | + if (!isset($globalLiveInterval)) { |
|
| 260 | + $globalLiveInterval = '200'; |
|
| 261 | + } |
|
| 247 | 262 | $filter_query = $this->getFilter($filter); |
| 248 | 263 | |
| 249 | 264 | if (is_array($coord)) { |
@@ -251,7 +266,9 @@ discard block |
||
| 251 | 266 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 252 | 267 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 253 | 268 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 254 | - } else return array(); |
|
| 269 | + } else { |
|
| 270 | + return array(); |
|
| 271 | + } |
|
| 255 | 272 | if ($globalDBdriver == 'mysql') { |
| 256 | 273 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 257 | 274 | } else { |
@@ -271,7 +288,9 @@ discard block |
||
| 271 | 288 | { |
| 272 | 289 | global $globalDBdriver, $globalLiveInterval; |
| 273 | 290 | $Spotter = new Spotter($this->db); |
| 274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 291 | + if (!isset($globalLiveInterval)) { |
|
| 292 | + $globalLiveInterval = '200'; |
|
| 293 | + } |
|
| 275 | 294 | $filter_query = $this->getFilter($filter); |
| 276 | 295 | |
| 277 | 296 | if (is_array($coord)) { |
@@ -279,7 +298,9 @@ discard block |
||
| 279 | 298 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 280 | 299 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 281 | 300 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 282 | - } else return array(); |
|
| 301 | + } else { |
|
| 302 | + return array(); |
|
| 303 | + } |
|
| 283 | 304 | if ($globalDBdriver == 'mysql') { |
| 284 | 305 | $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 |
| 285 | 306 | 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' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -472,11 +493,15 @@ discard block |
||
| 472 | 493 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 473 | 494 | if ($globalDBdriver == 'mysql') { |
| 474 | 495 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 475 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 496 | + if ($liveinterval) { |
|
| 497 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 498 | + } |
|
| 476 | 499 | $query .= ' ORDER BY date'; |
| 477 | 500 | } else { |
| 478 | 501 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 479 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 502 | + if ($liveinterval) { |
|
| 503 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 504 | + } |
|
| 480 | 505 | $query .= ' ORDER BY date'; |
| 481 | 506 | } |
| 482 | 507 | |
@@ -571,7 +596,9 @@ discard block |
||
| 571 | 596 | $i++; |
| 572 | 597 | $j++; |
| 573 | 598 | if ($j == 30) { |
| 574 | - if ($globalDebug) echo "."; |
|
| 599 | + if ($globalDebug) { |
|
| 600 | + echo "."; |
|
| 601 | + } |
|
| 575 | 602 | try { |
| 576 | 603 | |
| 577 | 604 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -818,7 +845,9 @@ discard block |
||
| 818 | 845 | { |
| 819 | 846 | return false; |
| 820 | 847 | } |
| 821 | - } else return ''; |
|
| 848 | + } else { |
|
| 849 | + return ''; |
|
| 850 | + } |
|
| 822 | 851 | |
| 823 | 852 | if ($longitude != '') |
| 824 | 853 | { |
@@ -826,7 +855,9 @@ discard block |
||
| 826 | 855 | { |
| 827 | 856 | return false; |
| 828 | 857 | } |
| 829 | - } else return ''; |
|
| 858 | + } else { |
|
| 859 | + return ''; |
|
| 860 | + } |
|
| 830 | 861 | |
| 831 | 862 | if ($altitude != '') |
| 832 | 863 | { |
@@ -834,7 +865,9 @@ discard block |
||
| 834 | 865 | { |
| 835 | 866 | return false; |
| 836 | 867 | } |
| 837 | - } else $altitude = 0; |
|
| 868 | + } else { |
|
| 869 | + $altitude = 0; |
|
| 870 | + } |
|
| 838 | 871 | |
| 839 | 872 | if ($heading != '') |
| 840 | 873 | { |
@@ -842,7 +875,9 @@ discard block |
||
| 842 | 875 | { |
| 843 | 876 | return false; |
| 844 | 877 | } |
| 845 | - } else $heading = 0; |
|
| 878 | + } else { |
|
| 879 | + $heading = 0; |
|
| 880 | + } |
|
| 846 | 881 | |
| 847 | 882 | if ($groundspeed != '') |
| 848 | 883 | { |
@@ -850,9 +885,13 @@ discard block |
||
| 850 | 885 | { |
| 851 | 886 | return false; |
| 852 | 887 | } |
| 853 | - } else $groundspeed = 0; |
|
| 888 | + } else { |
|
| 889 | + $groundspeed = 0; |
|
| 890 | + } |
|
| 854 | 891 | date_default_timezone_set('UTC'); |
| 855 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 892 | + if ($date == '') { |
|
| 893 | + $date = date("Y-m-d H:i:s", time()); |
|
| 894 | + } |
|
| 856 | 895 | |
| 857 | 896 | |
| 858 | 897 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -868,12 +907,18 @@ discard block |
||
| 868 | 907 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 869 | 908 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 870 | 909 | |
| 871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 910 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 911 | + $groundspeed = 0; |
|
| 912 | + } |
|
| 913 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 914 | + $heading = 0; |
|
| 915 | + } |
|
| 873 | 916 | |
| 874 | 917 | $query = ''; |
| 875 | 918 | if ($globalArchive) { |
| 876 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 919 | + if ($globalDebug) { |
|
| 920 | + echo '-- Delete previous data -- '; |
|
| 921 | + } |
|
| 877 | 922 | $query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;'; |
| 878 | 923 | } |
| 879 | 924 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
@@ -890,10 +935,14 @@ discard block |
||
| 890 | 935 | echo 'putinarchive : '.$putinarchive."\n"; |
| 891 | 936 | echo 'noarchive : '.$noarchive."\n"; |
| 892 | 937 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 893 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 938 | + if ($globalDebug) { |
|
| 939 | + echo '(Add to SBS archive : '; |
|
| 940 | + } |
|
| 894 | 941 | $TrackerArchive = new TrackerArchive($this->db); |
| 895 | 942 | $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.')'; |
|
| 943 | + if ($globalDebug) { |
|
| 944 | + echo $result.')'; |
|
| 945 | + } |
|
| 897 | 946 | } |
| 898 | 947 | |
| 899 | 948 | return "success"; |