@@ -3,7 +3,7 @@ |
||
3 | 3 | $type = 'aircraft'; |
4 | 4 | if (isset($_GET['marine'])) $type = 'marine'; |
5 | 5 | elseif (isset($_GET['tracker'])) $type = 'tracker'; |
6 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
6 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
7 | 7 | if ($date == '') $date = date('Y-m-d'); |
8 | 8 | if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
9 | 9 | elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
@@ -1,11 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $type = 'aircraft'; |
4 | -if (isset($_GET['marine'])) $type = 'marine'; |
|
5 | -elseif (isset($_GET['tracker'])) $type = 'tracker'; |
|
4 | +if (isset($_GET['marine'])) { |
|
5 | + $type = 'marine'; |
|
6 | +} elseif (isset($_GET['tracker'])) { |
|
7 | + $type = 'tracker'; |
|
8 | +} |
|
6 | 9 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
7 | -if ($date == '') $date = date('Y-m-d'); |
|
8 | -if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
|
9 | -elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
10 | -else header('Location: '.$globalURL.'/date/'.$date); |
|
10 | +if ($date == '') { |
|
11 | + $date = date('Y-m-d'); |
|
12 | +} |
|
13 | +if ($type == 'marine') { |
|
14 | + header('Location: '.$globalURL.'/marine/date/'.$date); |
|
15 | +} elseif ($type == 'tracker') { |
|
16 | + header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
17 | +} else { |
|
18 | + header('Location: '.$globalURL.'/date/'.$date); |
|
19 | +} |
|
11 | 20 | ?> |
12 | 21 | \ No newline at end of file |
@@ -2,34 +2,34 @@ discard block |
||
2 | 2 | require_once('require/class.Connection.php'); |
3 | 3 | require_once('require/class.Language.php'); |
4 | 4 | $type = ''; |
5 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
5 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
6 | 6 | if (isset($_GET['marine'])) { |
7 | - require_once('require/class.Marine.php');; |
|
7 | + require_once('require/class.Marine.php'); ; |
|
8 | 8 | $Marine = new Marine(); |
9 | 9 | $type = 'marine'; |
10 | 10 | $page_url = $globalURL.'/marine/date/'.$date; |
11 | 11 | } elseif (isset($_GET['tracker'])) { |
12 | - require_once('require/class.Tracker.php');; |
|
12 | + require_once('require/class.Tracker.php'); ; |
|
13 | 13 | $Tracker = new Tracker(); |
14 | 14 | $type = 'tracker'; |
15 | 15 | $page_url = $globalURL.'/tracker/date/'.$date; |
16 | 16 | } else { |
17 | - require_once('require/class.Spotter.php');; |
|
17 | + require_once('require/class.Spotter.php'); ; |
|
18 | 18 | $Spotter = new Spotter(); |
19 | 19 | $type = 'aircraft'; |
20 | 20 | $page_url = $globalURL.'/date/'.$date; |
21 | 21 | } |
22 | 22 | |
23 | -if (!isset($_GET['date'])){ |
|
23 | +if (!isset($_GET['date'])) { |
|
24 | 24 | header('Location: '.$globalURL.''); |
25 | 25 | } else { |
26 | 26 | //calculuation for the pagination |
27 | - if(!isset($_GET['limit'])) |
|
27 | + if (!isset($_GET['limit'])) |
|
28 | 28 | { |
29 | 29 | $limit_start = 0; |
30 | 30 | $limit_end = 25; |
31 | 31 | $absolute_difference = 25; |
32 | - } else { |
|
32 | + } else { |
|
33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
34 | 34 | $limit_start = $limit_explode[0]; |
35 | 35 | $limit_end = $limit_explode[1]; |
@@ -43,24 +43,24 @@ discard block |
||
43 | 43 | $limit_previous_1 = $limit_start - $absolute_difference; |
44 | 44 | $limit_previous_2 = $limit_end - $absolute_difference; |
45 | 45 | |
46 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
46 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
47 | 47 | if ($sort != '') |
48 | 48 | { |
49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
49 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
50 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
51 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
52 | 52 | } else { |
53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
53 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference); |
|
54 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference); |
|
55 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (!empty($spotter_array)) |
59 | 59 | { |
60 | 60 | date_default_timezone_set($globalTimezone); |
61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
61 | + if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | + elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | + else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
64 | 64 | |
65 | 65 | require_once('header.php'); |
66 | 66 | print '<div class="select-item">'; |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
79 | 79 | print '<br />'; |
80 | 80 | print '<div class="info column">'; |
81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
81 | + if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | + else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
83 | 83 | print '</div>'; |
84 | 84 | |
85 | 85 | if ($type == 'aircraft') include('date-sub-menu.php'); |
86 | 86 | print '<div class="table column">'; |
87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
87 | + if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | + elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | + else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
90 | 90 | |
91 | 91 | include('table-output.php'); |
92 | 92 | print '<div class="pagination">'; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $limit_start = 0; |
30 | 30 | $limit_end = 25; |
31 | 31 | $absolute_difference = 25; |
32 | - } else { |
|
32 | + } else { |
|
33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
34 | 34 | $limit_start = $limit_explode[0]; |
35 | 35 | $limit_end = $limit_explode[1]; |
@@ -46,21 +46,33 @@ discard block |
||
46 | 46 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
47 | 47 | if ($sort != '') |
48 | 48 | { |
49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
49 | + if ($type == 'marine') { |
|
50 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | + } elseif ($type == 'tracker') { |
|
52 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
53 | + } else { |
|
54 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
55 | + } |
|
52 | 56 | } else { |
53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
57 | + if ($type == 'marine') { |
|
58 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
59 | + } elseif ($type == 'tracker') { |
|
60 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
61 | + } else { |
|
62 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
63 | + } |
|
56 | 64 | } |
57 | 65 | |
58 | 66 | if (!empty($spotter_array)) |
59 | 67 | { |
60 | 68 | date_default_timezone_set($globalTimezone); |
61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
69 | + if ($type == 'marine') { |
|
70 | + $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
71 | + } elseif ($type == 'tracker') { |
|
72 | + $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
73 | + } else { |
|
74 | + $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
75 | + } |
|
64 | 76 | |
65 | 77 | require_once('header.php'); |
66 | 78 | print '<div class="select-item">'; |
@@ -78,15 +90,24 @@ discard block |
||
78 | 90 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
79 | 91 | print '<br />'; |
80 | 92 | print '<div class="info column">'; |
81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
93 | + if ($type == 'marine') { |
|
94 | + print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
95 | + } else { |
|
96 | + print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
97 | + } |
|
83 | 98 | print '</div>'; |
84 | 99 | |
85 | - if ($type == 'aircraft') include('date-sub-menu.php'); |
|
100 | + if ($type == 'aircraft') { |
|
101 | + include('date-sub-menu.php'); |
|
102 | + } |
|
86 | 103 | print '<div class="table column">'; |
87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
104 | + if ($type == 'marine') { |
|
105 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
106 | + } elseif ($type == 'tracker') { |
|
107 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
108 | + } else { |
|
109 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
110 | + } |
|
90 | 111 | |
91 | 112 | include('table-output.php'); |
92 | 113 | print '<div class="pagination">'; |
@@ -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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - 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]['hex']." - format : ".$line['format_source']."!!!"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - 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]['hex']." - format : ".$line['format_source']."!!!"; |
|
163 | + if ($globalDebug) { |
|
164 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - 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]['hex']." - format : ".$line['format_source']."!!!"; |
|
171 | + if ($globalDebug) { |
|
172 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - 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 | } |